From 57c0dbccd302f9a093c8e9f21d2b0db0b381f3d9 Mon Sep 17 00:00:00 2001 From: kaustubh Date: Wed, 26 Aug 2026 22:54:20 +0530 Subject: [PATCH 1/4] feat: add ndarray/base/kernels/generic/binary-strided1d/unblocked --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../binary-strided1d/unblocked/README.md | 1794 +++++++++++++++++ .../binary-strided1d/unblocked/docs/repl.txt | 510 +++++ .../unblocked/examples/index.js | 119 ++ .../binary-strided1d/unblocked/lib/0d.js | 137 ++ .../binary-strided1d/unblocked/lib/10d.js | 399 ++++ .../binary-strided1d/unblocked/lib/1d.js | 199 ++ .../binary-strided1d/unblocked/lib/2d.js | 237 +++ .../binary-strided1d/unblocked/lib/3d.js | 257 +++ .../binary-strided1d/unblocked/lib/4d.js | 277 +++ .../binary-strided1d/unblocked/lib/5d.js | 297 +++ .../binary-strided1d/unblocked/lib/6d.js | 319 +++ .../binary-strided1d/unblocked/lib/7d.js | 339 ++++ .../binary-strided1d/unblocked/lib/8d.js | 359 ++++ .../binary-strided1d/unblocked/lib/9d.js | 379 ++++ .../binary-strided1d/unblocked/lib/index.js | 175 ++ .../binary-strided1d/unblocked/lib/main.js | 185 ++ .../binary-strided1d/unblocked/package.json | 65 + .../binary-strided1d/unblocked/test/test.js | 35 + 18 files changed, 6082 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/README.md create mode 100644 lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/examples/index.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/0d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/10d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/1d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/2d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/3d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/4d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/5d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/6d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/7d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/8d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/9d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/index.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/main.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/package.json create mode 100644 lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/test/test.js diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/README.md b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/README.md new file mode 100644 index 000000000000..02a8d233eaca --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/README.md @@ -0,0 +1,1794 @@ + + +# kernel + +> Return a kernel for applying a one-dimensional strided array function to two input ndarrays and assigning results to an output ndarray. + +
+ +
+ + + +
+ +## Usage + +```javascript +var kernel = require( '@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked' ); +``` + +#### kernel( ndims ) + +Returns a kernel for applying a one-dimensional strided array function to two input ndarrays and assigning results to an output ndarray. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var gwxpy = require( '@stdlib/blas/ext/base/ndarray/gwxpy' ); + +// 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( [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0 ] ); +var zbuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + +// Define the array shapes: +var xsh = [ 1, 3, 2, 2 ]; +var ysh = [ 1, 3, 2, 2 ]; +var zsh = [ 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 ]; + +// Define the index offsets: +var ox = 0; +var oy = 0; +var oz = 0; + +// Create the input ndarray descriptors: +var x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': xsh, + 'strides': sx, + 'offset': ox, + 'order': 'row-major' +}; + +var y = { + 'dtype': 'float64', + 'data': ybuf, + 'shape': ysh, + 'strides': sy, + 'offset': oy, + 'order': 'row-major' +}; + +// Create an output ndarray descriptor: +var z = { + 'dtype': 'float64', + 'data': zbuf, + 'shape': zsh, + 'strides': sz, + 'offset': oz, + 'order': 'row-major' +}; + +// Initialize ndarray descriptors representing subarray views: +var views = [ + { + 'dtype': x.dtype, + 'data': x.data, + 'shape': [ 2, 2 ], + 'strides': [ 2, 1 ], + 'offset': x.offset, + 'order': x.order + }, + { + 'dtype': y.dtype, + 'data': y.data, + 'shape': [ 2, 2 ], + 'strides': [ 2, 1 ], + 'offset': y.offset, + 'order': y.order + }, + { + 'dtype': z.dtype, + 'data': z.data, + 'shape': [ 2, 2 ], + 'strides': [ 2, 1 ], + 'offset': z.offset, + 'order': z.order + } +]; + +// Define an input strategy: +function inputStrategy( x ) { + return { + 'dtype': x.dtype, + 'data': x.data, + 'shape': [ 4 ], + 'strides': [ 1 ], + 'offset': x.offset, + 'order': x.order + }; +} + +// Define an output strategy: +function outputStrategy( x ) { + return x; +} + +var strategy = { + 'input': inputStrategy, + 'output': outputStrategy +}; + +// Resolve a kernel: +var f = kernel( 2 ); + +// Apply strided function: +f( gwxpy, [ x, y, z ], views, [ 1, 3 ], [ 12, 4 ], [ 12, 4 ], [ 12, 4 ], strategy, strategy, strategy, {} ); + +var arr = ndarray2array( z.data, z.shape, z.strides, z.offset, z.order ); +// returns [ [ [ [ 3.0, 5.0 ], [ 7.0, 9.0 ] ], [ [ 11.0, 13.0 ], [ 15.0, 17.0 ] ], [ [ 19.0, 21.0 ], [ 23.0, 25.0 ] ] ] ] +``` + +The function accepts the following arguments: + +- **ndims**: number of loop dimensions. + +If the function is provided an `ndims` value greater than the maximum number of supported loop dimensions, the function returns `null`. + +```javascript +var f = kernel( 100000 ); +// returns null +``` + +The returned function accepts the following arguments: + +- **fcn**: function which will be applied to two one-dimensional input subarrays and should update a one-dimensional output subarray with results. +- **arrays**: array containing two input ndarray [descriptors][@stdlib/ndarray/base/descriptor] and one output ndarray [descriptor][@stdlib/ndarray/base/descriptor], followed by any additional ndarray arguments. +- **views**: initialized ndarray [descriptors][@stdlib/ndarray/base/descriptor] representing subarray views. +- **shape**: loop dimensions. +- **stridesX**: loop dimension strides for the first input ndarray. +- **stridesY**: loop dimension strides for the second input ndarray. +- **stridesZ**: loop dimension strides for the output ndarray. +- **strategyX**: strategy for marshaling data to and from a first input ndarray view. +- **strategyY**: strategy for marshaling data to and from a second input ndarray view. +- **strategyZ**: strategy for marshaling data to and from an output ndarray view. +- **options**: function options which are passed through to `fcn`. + +The returned function iterates over ndarray elements according to the memory layout of the first input ndarray. + + + +#### kernel.kernel.kernel0d( fcn, arrays, views, shape, stridesX, strideY, strideZ, strategyX, strategyY, strategyZ, options ) + + + +Applies a one-dimensional strided array function to a list of specified dimensions in two input ndarrays and assigns results to a provided output ndarray. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var gwxpy = require( '@stdlib/blas/ext/base/ndarray/gwxpy' ); + +// Create data buffers: +var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +var ybuf = new Float64Array( [ 2.0, 3.0, 4.0, 5.0 ] ); +var zbuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + +// Define the array shapes: +var xsh = [ 2, 2 ]; +var ysh = [ 2, 2 ]; +var zsh = [ 2, 2 ]; + +// Define the array strides: +var sx = [ 2, 1 ]; +var sy = [ 2, 1 ]; +var sz = [ 2, 1 ]; + +// Define the index offsets: +var ox = 0; +var oy = 0; +var oz = 0; + +// Create the input ndarray descriptors: +var x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': xsh, + 'strides': sx, + 'offset': ox, + 'order': 'row-major' +}; + +var y = { + 'dtype': 'float64', + 'data': ybuf, + 'shape': ysh, + 'strides': sy, + 'offset': oy, + 'order': 'row-major' +}; + +// Create an output ndarray descriptor: +var z = { + 'dtype': 'float64', + 'data': zbuf, + 'shape': zsh, + 'strides': sz, + 'offset': oz, + 'order': 'row-major' +}; + +// Define an input strategy: +function inputStrategy( x ) { + return { + 'dtype': x.dtype, + 'data': x.data, + 'shape': [ 4 ], + 'strides': [ 1 ], + 'offset': x.offset, + 'order': x.order + }; +} + +// Define an output strategy: +function outputStrategy( x ) { + return x; +} + +var strategy = { + 'input': inputStrategy, + 'output': outputStrategy +}; + +// Apply strided function: +kernel.kernel0d( gwxpy, [ x, y, z ], [], [], [], [], [], strategy, strategy, strategy, {} ); + +var v = z.data; +// returns [ 3.0, 5.0, 7.0, 9.0 ] +``` + +The function has the following parameters: + +- **fcn**: function which will be applied to two one-dimensional input subarrays and should update a one-dimensional output subarray with results. +- **arrays**: array containing two input ndarray [descriptors][@stdlib/ndarray/base/descriptor] and one output ndarray [descriptor][@stdlib/ndarray/base/descriptor], followed by any additional ndarray arguments. +- **views**: initialized ndarray [descriptors][@stdlib/ndarray/base/descriptor] representing subarray views. +- **shape**: loop dimensions. Should have zero elements. +- **stridesX**: loop dimension strides for the first input ndarray. +- **stridesY**: loop dimension strides for the second input ndarray. +- **stridesZ**: loop dimension strides for the output ndarray. +- **strategyX**: strategy for marshaling data to and from a first input ndarray view. +- **strategyY**: strategy for marshaling data to and from a second input ndarray view. +- **strategyZ**: strategy for marshaling data to and from an output ndarray view. +- **options**: function options which are passed through to `fcn`. + +The `views`, `shape`, `stridesX`, `stridesY`, and `stridesZ` parameters are unused. Providing empty arrays for these parameters is recommended in order to ensure a monomorphic API. + + + +#### kernel.kernel.kernel1d( fcn, arrays, views, shape, stridesX, strideY, strideZ, strategyX, strategyY, strategyZ, options ) + + + +Applies a one-dimensional strided array function to a list of specified dimensions in two input ndarrays and assigns results to a provided output ndarray. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var gwxpy = require( '@stdlib/blas/ext/base/ndarray/gwxpy' ); + +// 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( [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0 ] ); +var zbuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + +// Define the array shapes: +var xsh = [ 3, 2, 2 ]; +var ysh = [ 3, 2, 2 ]; +var zsh = [ 3, 2, 2 ]; + +// Define the array strides: +var sx = [ 4, 2, 1 ]; +var sy = [ 4, 2, 1 ]; +var sz = [ 4, 2, 1 ]; + +// Define the index offsets: +var ox = 0; +var oy = 0; +var oz = 0; + +// Create the input ndarray descriptors: +var x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': xsh, + 'strides': sx, + 'offset': ox, + 'order': 'row-major' +}; + +var y = { + 'dtype': 'float64', + 'data': ybuf, + 'shape': ysh, + 'strides': sy, + 'offset': oy, + 'order': 'row-major' +}; + +// Create an output ndarray descriptor: +var z = { + 'dtype': 'float64', + 'data': zbuf, + 'shape': zsh, + 'strides': sz, + 'offset': oz, + 'order': 'row-major' +}; + +// Initialize ndarray descriptors representing subarray views: +var views = [ + { + 'dtype': x.dtype, + 'data': x.data, + 'shape': [ 2, 2 ], + 'strides': [ 2, 1 ], + 'offset': x.offset, + 'order': x.order + }, + { + 'dtype': y.dtype, + 'data': y.data, + 'shape': [ 2, 2 ], + 'strides': [ 2, 1 ], + 'offset': y.offset, + 'order': y.order + }, + { + 'dtype': z.dtype, + 'data': z.data, + 'shape': [ 2, 2 ], + 'strides': [ 2, 1 ], + 'offset': z.offset, + 'order': z.order + } +]; + +// Define an input strategy: +function inputStrategy( x ) { + return { + 'dtype': x.dtype, + 'data': x.data, + 'shape': [ 4 ], + 'strides': [ 1 ], + 'offset': x.offset, + 'order': x.order + }; +} + +// Define an output strategy: +function outputStrategy( x ) { + return x; +} + +var strategy = { + 'input': inputStrategy, + 'output': outputStrategy +}; + +// Apply strided function: +kernel.kernel1d( gwxpy, [ x, y, z ], views, [ 3 ], [ 4 ], [ 4 ], [ 4 ], strategy, strategy, strategy, {} ); + +var arr = ndarray2array( z.data, z.shape, z.strides, z.offset, z.order ); +// returns [ [ [ 3.0, 5.0 ], [ 7.0, 9.0 ] ], [ [ 11.0, 13.0 ], [ 15.0, 17.0 ] ], [ [ 19.0, 21.0 ], [ 23.0, 25.0 ] ] ] +``` + +The function has the following parameters: + +- **fcn**: function which will be applied to two one-dimensional input subarrays and should update a one-dimensional output subarray with results. +- **arrays**: array containing two input ndarray [descriptors][@stdlib/ndarray/base/descriptor] and one output ndarray [descriptor][@stdlib/ndarray/base/descriptor], followed by any additional ndarray arguments. +- **views**: initialized ndarray [descriptors][@stdlib/ndarray/base/descriptor] representing subarray views. +- **shape**: loop dimensions. Should have one element. +- **stridesX**: loop dimension strides for the first input ndarray. +- **stridesY**: loop dimension strides for the second input ndarray. +- **stridesZ**: loop dimension strides for the output ndarray. +- **strategyX**: strategy for marshaling data to and from a first input ndarray view. +- **strategyY**: strategy for marshaling data to and from a second input ndarray view. +- **strategyZ**: strategy for marshaling data to and from an output ndarray view. +- **options**: function options which are passed through to `fcn`. + + + +#### kernel.kernel.kernel2d( fcn, arrays, views, shape, stridesX, strideY, strideZ, strategyX, strategyY, strategyZ, options ) + + + +Applies a one-dimensional strided array function to a list of specified dimensions in two input ndarrays and assigns results to a provided output ndarray. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var gwxpy = require( '@stdlib/blas/ext/base/ndarray/gwxpy' ); + +// 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( [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0 ] ); +var zbuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + +// Define the array shapes: +var xsh = [ 1, 3, 2, 2 ]; +var ysh = [ 1, 3, 2, 2 ]; +var zsh = [ 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 ]; + +// Define the index offsets: +var ox = 0; +var oy = 0; +var oz = 0; + +// Create the input ndarray descriptors: +var x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': xsh, + 'strides': sx, + 'offset': ox, + 'order': 'row-major' +}; + +var y = { + 'dtype': 'float64', + 'data': ybuf, + 'shape': ysh, + 'strides': sy, + 'offset': oy, + 'order': 'row-major' +}; + +// Create an output ndarray descriptor: +var z = { + 'dtype': 'float64', + 'data': zbuf, + 'shape': zsh, + 'strides': sz, + 'offset': oz, + 'order': 'row-major' +}; + +// Initialize ndarray descriptors representing subarray views: +var views = [ + { + 'dtype': x.dtype, + 'data': x.data, + 'shape': [ 2, 2 ], + 'strides': [ 2, 1 ], + 'offset': x.offset, + 'order': x.order + }, + { + 'dtype': y.dtype, + 'data': y.data, + 'shape': [ 2, 2 ], + 'strides': [ 2, 1 ], + 'offset': y.offset, + 'order': y.order + }, + { + 'dtype': z.dtype, + 'data': z.data, + 'shape': [ 2, 2 ], + 'strides': [ 2, 1 ], + 'offset': z.offset, + 'order': z.order + } +]; + +// Define an input strategy: +function inputStrategy( x ) { + return { + 'dtype': x.dtype, + 'data': x.data, + 'shape': [ 4 ], + 'strides': [ 1 ], + 'offset': x.offset, + 'order': x.order + }; +} + +// Define an output strategy: +function outputStrategy( x ) { + return x; +} + +var strategy = { + 'input': inputStrategy, + 'output': outputStrategy +}; + +// Apply strided function: +kernel.kernel2d( gwxpy, [ x, y, z ], views, [ 1, 3 ], [ 12, 4 ], [ 12, 4 ], [ 12, 4 ], strategy, strategy, strategy, {} ); + +var arr = ndarray2array( z.data, z.shape, z.strides, z.offset, z.order ); +// returns [ [ [ [ 3.0, 5.0 ], [ 7.0, 9.0 ] ], [ [ 11.0, 13.0 ], [ 15.0, 17.0 ] ], [ [ 19.0, 21.0 ], [ 23.0, 25.0 ] ] ] ] +``` + +The function has the following parameters: + +- **fcn**: function which will be applied to two one-dimensional input subarrays and should update a one-dimensional output subarray with results. +- **arrays**: array containing two input ndarray [descriptors][@stdlib/ndarray/base/descriptor] and one output ndarray [descriptor][@stdlib/ndarray/base/descriptor], followed by any additional ndarray arguments. +- **views**: initialized ndarray [descriptors][@stdlib/ndarray/base/descriptor] representing subarray views. +- **shape**: loop dimensions. Should have two elements. +- **stridesX**: loop dimension strides for the first input ndarray. +- **stridesY**: loop dimension strides for the second input ndarray. +- **stridesZ**: loop dimension strides for the output ndarray. +- **strategyX**: strategy for marshaling data to and from a first input ndarray view. +- **strategyY**: strategy for marshaling data to and from a second input ndarray view. +- **strategyZ**: strategy for marshaling data to and from an output ndarray view. +- **options**: function options which are passed through to `fcn`. + + + +#### kernel.kernel.kernel3d( fcn, arrays, views, shape, stridesX, strideY, strideZ, strategyX, strategyY, strategyZ, options ) + + + +Applies a one-dimensional strided array function to a list of specified dimensions in two input ndarrays and assigns results to a provided output ndarray. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var gwxpy = require( '@stdlib/blas/ext/base/ndarray/gwxpy' ); + +// 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( [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0 ] ); +var zbuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + +// Define the array shapes: +var xsh = [ 1, 1, 3, 2, 2 ]; +var ysh = [ 1, 1, 3, 2, 2 ]; +var zsh = [ 1, 1, 3, 2, 2 ]; + +// Define the array strides: +var sx = [ 12, 12, 4, 2, 1 ]; +var sy = [ 12, 12, 4, 2, 1 ]; +var sz = [ 12, 12, 4, 2, 1 ]; + +// Define the index offsets: +var ox = 0; +var oy = 0; +var oz = 0; + +// Create the input ndarray descriptors: +var x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': xsh, + 'strides': sx, + 'offset': ox, + 'order': 'row-major' +}; + +var y = { + 'dtype': 'float64', + 'data': ybuf, + 'shape': ysh, + 'strides': sy, + 'offset': oy, + 'order': 'row-major' +}; + +// Create an output ndarray descriptor: +var z = { + 'dtype': 'float64', + 'data': zbuf, + 'shape': zsh, + 'strides': sz, + 'offset': oz, + 'order': 'row-major' +}; + +// Initialize ndarray descriptors representing subarray views: +var views = [ + { + 'dtype': x.dtype, + 'data': x.data, + 'shape': [ 2, 2 ], + 'strides': [ 2, 1 ], + 'offset': x.offset, + 'order': x.order + }, + { + 'dtype': y.dtype, + 'data': y.data, + 'shape': [ 2, 2 ], + 'strides': [ 2, 1 ], + 'offset': y.offset, + 'order': y.order + }, + { + 'dtype': z.dtype, + 'data': z.data, + 'shape': [ 2, 2 ], + 'strides': [ 2, 1 ], + 'offset': z.offset, + 'order': z.order + } +]; + +// Define an input strategy: +function inputStrategy( x ) { + return { + 'dtype': x.dtype, + 'data': x.data, + 'shape': [ 4 ], + 'strides': [ 1 ], + 'offset': x.offset, + 'order': x.order + }; +} + +// Define an output strategy: +function outputStrategy( x ) { + return x; +} + +var strategy = { + 'input': inputStrategy, + 'output': outputStrategy +}; + +// Apply strided function: +kernel.kernel3d( gwxpy, [ x, y, z ], views, [ 1, 1, 3 ], [ 12, 12, 4 ], [ 12, 12, 4 ], [ 12, 12, 4 ], strategy, strategy, strategy, {} ); + +var arr = ndarray2array( z.data, z.shape, z.strides, z.offset, z.order ); +// returns [ [ [ [ [ 3.0, 5.0 ], [ 7.0, 9.0 ] ], [ [ 11.0, 13.0 ], [ 15.0, 17.0 ] ], [ [ 19.0, 21.0 ], [ 23.0, 25.0 ] ] ] ] ] +``` + +The function has the following parameters: + +- **fcn**: function which will be applied to two one-dimensional input subarrays and should update a one-dimensional output subarray with results. +- **arrays**: array containing two input ndarray [descriptors][@stdlib/ndarray/base/descriptor] and one output ndarray [descriptor][@stdlib/ndarray/base/descriptor], followed by any additional ndarray arguments. +- **views**: initialized ndarray [descriptors][@stdlib/ndarray/base/descriptor] representing subarray views. +- **shape**: loop dimensions. Should have three elements. +- **stridesX**: loop dimension strides for the first input ndarray. +- **stridesY**: loop dimension strides for the second input ndarray. +- **stridesZ**: loop dimension strides for the output ndarray. +- **strategyX**: strategy for marshaling data to and from a first input ndarray view. +- **strategyY**: strategy for marshaling data to and from a second input ndarray view. +- **strategyZ**: strategy for marshaling data to and from an output ndarray view. +- **options**: function options which are passed through to `fcn`. + + + +#### kernel.kernel.kernel4d( fcn, arrays, views, shape, stridesX, strideY, strideZ, strategyX, strategyY, strategyZ, options ) + + + +Applies a one-dimensional strided array function to a list of specified dimensions in two input ndarrays and assigns results to a provided output ndarray. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var gwxpy = require( '@stdlib/blas/ext/base/ndarray/gwxpy' ); + +// 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( [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0 ] ); +var zbuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + +// Define the array shapes: +var xsh = [ 1, 1, 1, 3, 2, 2 ]; +var ysh = [ 1, 1, 1, 3, 2, 2 ]; +var zsh = [ 1, 1, 1, 3, 2, 2 ]; + +// Define the array strides: +var sx = [ 12, 12, 12, 4, 2, 1 ]; +var sy = [ 12, 12, 12, 4, 2, 1 ]; +var sz = [ 12, 12, 12, 4, 2, 1 ]; + +// Define the index offsets: +var ox = 0; +var oy = 0; +var oz = 0; + +// Create the input ndarray descriptors: +var x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': xsh, + 'strides': sx, + 'offset': ox, + 'order': 'row-major' +}; + +var y = { + 'dtype': 'float64', + 'data': ybuf, + 'shape': ysh, + 'strides': sy, + 'offset': oy, + 'order': 'row-major' +}; + +// Create an output ndarray descriptor: +var z = { + 'dtype': 'float64', + 'data': zbuf, + 'shape': zsh, + 'strides': sz, + 'offset': oz, + 'order': 'row-major' +}; + +// Initialize ndarray descriptors representing subarray views: +var views = [ + { + 'dtype': x.dtype, + 'data': x.data, + 'shape': [ 2, 2 ], + 'strides': [ 2, 1 ], + 'offset': x.offset, + 'order': x.order + }, + { + 'dtype': y.dtype, + 'data': y.data, + 'shape': [ 2, 2 ], + 'strides': [ 2, 1 ], + 'offset': y.offset, + 'order': y.order + }, + { + 'dtype': z.dtype, + 'data': z.data, + 'shape': [ 2, 2 ], + 'strides': [ 2, 1 ], + 'offset': z.offset, + 'order': z.order + } +]; + +// Define an input strategy: +function inputStrategy( x ) { + return { + 'dtype': x.dtype, + 'data': x.data, + 'shape': [ 4 ], + 'strides': [ 1 ], + 'offset': x.offset, + 'order': x.order + }; +} + +// Define an output strategy: +function outputStrategy( x ) { + return x; +} + +var strategy = { + 'input': inputStrategy, + 'output': outputStrategy +}; + +// Apply strided function: +kernel.kernel4d( gwxpy, [ x, y, z ], views, [ 1, 1, 1, 3 ], [ 12, 12, 12, 4 ], [ 12, 12, 12, 4 ], [ 12, 12, 12, 4 ], strategy, strategy, strategy, {} ); + +var arr = ndarray2array( z.data, z.shape, z.strides, z.offset, z.order ); +// returns [ [ [ [ [ [ 3.0, 5.0 ], [ 7.0, 9.0 ] ], [ [ 11.0, 13.0 ], [ 15.0, 17.0 ] ], [ [ 19.0, 21.0 ], [ 23.0, 25.0 ] ] ] ] ] ] +``` + +The function has the following parameters: + +- **fcn**: function which will be applied to two one-dimensional input subarrays and should update a one-dimensional output subarray with results. +- **arrays**: array containing two input ndarray [descriptors][@stdlib/ndarray/base/descriptor] and one output ndarray [descriptor][@stdlib/ndarray/base/descriptor], followed by any additional ndarray arguments. +- **views**: initialized ndarray [descriptors][@stdlib/ndarray/base/descriptor] representing subarray views. +- **shape**: loop dimensions. Should have four elements. +- **stridesX**: loop dimension strides for the first input ndarray. +- **stridesY**: loop dimension strides for the second input ndarray. +- **stridesZ**: loop dimension strides for the output ndarray. +- **strategyX**: strategy for marshaling data to and from a first input ndarray view. +- **strategyY**: strategy for marshaling data to and from a second input ndarray view. +- **strategyZ**: strategy for marshaling data to and from an output ndarray view. +- **options**: function options which are passed through to `fcn`. + + + +#### kernel.kernel.kernel5d( fcn, arrays, views, shape, stridesX, strideY, strideZ, strategyX, strategyY, strategyZ, options ) + + + +Applies a one-dimensional strided array function to a list of specified dimensions in two input ndarrays and assigns results to a provided output ndarray. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var gwxpy = require( '@stdlib/blas/ext/base/ndarray/gwxpy' ); + +// 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( [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0 ] ); +var zbuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + +// Define the array shapes: +var xsh = [ 1, 1, 1, 1, 3, 2, 2 ]; +var ysh = [ 1, 1, 1, 1, 3, 2, 2 ]; +var zsh = [ 1, 1, 1, 1, 3, 2, 2 ]; + +// Define the array strides: +var sx = [ 12, 12, 12, 12, 4, 2, 1 ]; +var sy = [ 12, 12, 12, 12, 4, 2, 1 ]; +var sz = [ 12, 12, 12, 12, 4, 2, 1 ]; + +// Define the index offsets: +var ox = 0; +var oy = 0; +var oz = 0; + +// Create the input ndarray descriptors: +var x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': xsh, + 'strides': sx, + 'offset': ox, + 'order': 'row-major' +}; + +var y = { + 'dtype': 'float64', + 'data': ybuf, + 'shape': ysh, + 'strides': sy, + 'offset': oy, + 'order': 'row-major' +}; + +// Create an output ndarray descriptor: +var z = { + 'dtype': 'float64', + 'data': zbuf, + 'shape': zsh, + 'strides': sz, + 'offset': oz, + 'order': 'row-major' +}; + +// Initialize ndarray descriptors representing subarray views: +var views = [ + { + 'dtype': x.dtype, + 'data': x.data, + 'shape': [ 2, 2 ], + 'strides': [ 2, 1 ], + 'offset': x.offset, + 'order': x.order + }, + { + 'dtype': y.dtype, + 'data': y.data, + 'shape': [ 2, 2 ], + 'strides': [ 2, 1 ], + 'offset': y.offset, + 'order': y.order + }, + { + 'dtype': z.dtype, + 'data': z.data, + 'shape': [ 2, 2 ], + 'strides': [ 2, 1 ], + 'offset': z.offset, + 'order': z.order + } +]; + +// Define an input strategy: +function inputStrategy( x ) { + return { + 'dtype': x.dtype, + 'data': x.data, + 'shape': [ 4 ], + 'strides': [ 1 ], + 'offset': x.offset, + 'order': x.order + }; +} + +// Define an output strategy: +function outputStrategy( x ) { + return x; +} + +var strategy = { + 'input': inputStrategy, + 'output': outputStrategy +}; + +// Apply strided function: +kernel.kernel5d( gwxpy, [ x, y, z ], views, [ 1, 1, 1, 1, 3 ], [ 12, 12, 12, 12, 4 ], [ 12, 12, 12, 12, 4 ], [ 12, 12, 12, 12, 4 ], strategy, strategy, strategy, {} ); + +var arr = ndarray2array( z.data, z.shape, z.strides, z.offset, z.order ); +// returns [ [ [ [ [ [ [ 3.0, 5.0 ], [ 7.0, 9.0 ] ], [ [ 11.0, 13.0 ], [ 15.0, 17.0 ] ], [ [ 19.0, 21.0 ], [ 23.0, 25.0 ] ] ] ] ] ] ] +``` + +The function has the following parameters: + +- **fcn**: function which will be applied to two one-dimensional input subarrays and should update a one-dimensional output subarray with results. +- **arrays**: array containing two input ndarray [descriptors][@stdlib/ndarray/base/descriptor] and one output ndarray [descriptor][@stdlib/ndarray/base/descriptor], followed by any additional ndarray arguments. +- **views**: initialized ndarray [descriptors][@stdlib/ndarray/base/descriptor] representing subarray views. +- **shape**: loop dimensions. Should have five elements. +- **stridesX**: loop dimension strides for the first input ndarray. +- **stridesY**: loop dimension strides for the second input ndarray. +- **stridesZ**: loop dimension strides for the output ndarray. +- **strategyX**: strategy for marshaling data to and from a first input ndarray view. +- **strategyY**: strategy for marshaling data to and from a second input ndarray view. +- **strategyZ**: strategy for marshaling data to and from an output ndarray view. +- **options**: function options which are passed through to `fcn`. + + + +#### kernel.kernel.kernel6d( fcn, arrays, views, shape, stridesX, strideY, strideZ, strategyX, strategyY, strategyZ, options ) + + + +Applies a one-dimensional strided array function to a list of specified dimensions in two input ndarrays and assigns results to a provided output ndarray. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var gwxpy = require( '@stdlib/blas/ext/base/ndarray/gwxpy' ); + +// 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( [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0 ] ); +var zbuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + +// Define the array shapes: +var xsh = [ 1, 1, 1, 1, 1, 3, 2, 2 ]; +var ysh = [ 1, 1, 1, 1, 1, 3, 2, 2 ]; +var zsh = [ 1, 1, 1, 1, 1, 3, 2, 2 ]; + +// Define the array strides: +var sx = [ 12, 12, 12, 12, 12, 4, 2, 1 ]; +var sy = [ 12, 12, 12, 12, 12, 4, 2, 1 ]; +var sz = [ 12, 12, 12, 12, 12, 4, 2, 1 ]; + +// Define the index offsets: +var ox = 0; +var oy = 0; +var oz = 0; + +// Create the input ndarray descriptors: +var x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': xsh, + 'strides': sx, + 'offset': ox, + 'order': 'row-major' +}; + +var y = { + 'dtype': 'float64', + 'data': ybuf, + 'shape': ysh, + 'strides': sy, + 'offset': oy, + 'order': 'row-major' +}; + +// Create an output ndarray descriptor: +var z = { + 'dtype': 'float64', + 'data': zbuf, + 'shape': zsh, + 'strides': sz, + 'offset': oz, + 'order': 'row-major' +}; + +// Initialize ndarray descriptors representing subarray views: +var views = [ + { + 'dtype': x.dtype, + 'data': x.data, + 'shape': [ 2, 2 ], + 'strides': [ 2, 1 ], + 'offset': x.offset, + 'order': x.order + }, + { + 'dtype': y.dtype, + 'data': y.data, + 'shape': [ 2, 2 ], + 'strides': [ 2, 1 ], + 'offset': y.offset, + 'order': y.order + }, + { + 'dtype': z.dtype, + 'data': z.data, + 'shape': [ 2, 2 ], + 'strides': [ 2, 1 ], + 'offset': z.offset, + 'order': z.order + } +]; + +// Define an input strategy: +function inputStrategy( x ) { + return { + 'dtype': x.dtype, + 'data': x.data, + 'shape': [ 4 ], + 'strides': [ 1 ], + 'offset': x.offset, + 'order': x.order + }; +} + +// Define an output strategy: +function outputStrategy( x ) { + return x; +} + +var strategy = { + 'input': inputStrategy, + 'output': outputStrategy +}; + +// Apply strided function: +kernel.kernel6d( gwxpy, [ x, y, z ], views, [ 1, 1, 1, 1, 1, 3 ], [ 12, 12, 12, 12, 12, 4 ], [ 12, 12, 12, 12, 12, 4 ], [ 12, 12, 12, 12, 12, 4 ], strategy, strategy, strategy, {} ); + +var arr = ndarray2array( z.data, z.shape, z.strides, z.offset, z.order ); +// returns [ [ [ [ [ [ [ [ 3.0, 5.0 ], [ 7.0, 9.0 ] ], [ [ 11.0, 13.0 ], [ 15.0, 17.0 ] ], [ [ 19.0, 21.0 ], [ 23.0, 25.0 ] ] ] ] ] ] ] ] +``` + +The function has the following parameters: + +- **fcn**: function which will be applied to two one-dimensional input subarrays and should update a one-dimensional output subarray with results. +- **arrays**: array containing two input ndarray [descriptors][@stdlib/ndarray/base/descriptor] and one output ndarray [descriptor][@stdlib/ndarray/base/descriptor], followed by any additional ndarray arguments. +- **views**: initialized ndarray [descriptors][@stdlib/ndarray/base/descriptor] representing subarray views. +- **shape**: loop dimensions. Should have six elements. +- **stridesX**: loop dimension strides for the first input ndarray. +- **stridesY**: loop dimension strides for the second input ndarray. +- **stridesZ**: loop dimension strides for the output ndarray. +- **strategyX**: strategy for marshaling data to and from a first input ndarray view. +- **strategyY**: strategy for marshaling data to and from a second input ndarray view. +- **strategyZ**: strategy for marshaling data to and from an output ndarray view. +- **options**: function options which are passed through to `fcn`. + + + +#### kernel.kernel.kernel7d( fcn, arrays, views, shape, stridesX, strideY, strideZ, strategyX, strategyY, strategyZ, options ) + + + +Applies a one-dimensional strided array function to a list of specified dimensions in two input ndarrays and assigns results to a provided output ndarray. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var gwxpy = require( '@stdlib/blas/ext/base/ndarray/gwxpy' ); + +// 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( [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0 ] ); +var zbuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + +// Define the array shapes: +var xsh = [ 1, 1, 1, 1, 1, 1, 3, 2, 2 ]; +var ysh = [ 1, 1, 1, 1, 1, 1, 3, 2, 2 ]; +var zsh = [ 1, 1, 1, 1, 1, 1, 3, 2, 2 ]; + +// Define the array strides: +var sx = [ 12, 12, 12, 12, 12, 12, 4, 2, 1 ]; +var sy = [ 12, 12, 12, 12, 12, 12, 4, 2, 1 ]; +var sz = [ 12, 12, 12, 12, 12, 12, 4, 2, 1 ]; + +// Define the index offsets: +var ox = 0; +var oy = 0; +var oz = 0; + +// Create the input ndarray descriptors: +var x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': xsh, + 'strides': sx, + 'offset': ox, + 'order': 'row-major' +}; + +var y = { + 'dtype': 'float64', + 'data': ybuf, + 'shape': ysh, + 'strides': sy, + 'offset': oy, + 'order': 'row-major' +}; + +// Create an output ndarray descriptor: +var z = { + 'dtype': 'float64', + 'data': zbuf, + 'shape': zsh, + 'strides': sz, + 'offset': oz, + 'order': 'row-major' +}; + +// Initialize ndarray descriptors representing subarray views: +var views = [ + { + 'dtype': x.dtype, + 'data': x.data, + 'shape': [ 2, 2 ], + 'strides': [ 2, 1 ], + 'offset': x.offset, + 'order': x.order + }, + { + 'dtype': y.dtype, + 'data': y.data, + 'shape': [ 2, 2 ], + 'strides': [ 2, 1 ], + 'offset': y.offset, + 'order': y.order + }, + { + 'dtype': z.dtype, + 'data': z.data, + 'shape': [ 2, 2 ], + 'strides': [ 2, 1 ], + 'offset': z.offset, + 'order': z.order + } +]; + +// Define an input strategy: +function inputStrategy( x ) { + return { + 'dtype': x.dtype, + 'data': x.data, + 'shape': [ 4 ], + 'strides': [ 1 ], + 'offset': x.offset, + 'order': x.order + }; +} + +// Define an output strategy: +function outputStrategy( x ) { + return x; +} + +var strategy = { + 'input': inputStrategy, + 'output': outputStrategy +}; + +// Apply strided function: +kernel.kernel7d( gwxpy, [ x, y, z ], views, [ 1, 1, 1, 1, 1, 1, 3 ], [ 12, 12, 12, 12, 12, 12, 4 ], [ 12, 12, 12, 12, 12, 12, 4 ], [ 12, 12, 12, 12, 12, 12, 4 ], strategy, strategy, strategy, {} ); + +var arr = ndarray2array( z.data, z.shape, z.strides, z.offset, z.order ); +// returns [ [ [ [ [ [ [ [ [ 3.0, 5.0 ], [ 7.0, 9.0 ] ], [ [ 11.0, 13.0 ], [ 15.0, 17.0 ] ], [ [ 19.0, 21.0 ], [ 23.0, 25.0 ] ] ] ] ] ] ] ] ] +``` + +The function has the following parameters: + +- **fcn**: function which will be applied to two one-dimensional input subarrays and should update a one-dimensional output subarray with results. +- **arrays**: array containing two input ndarray [descriptors][@stdlib/ndarray/base/descriptor] and one output ndarray [descriptor][@stdlib/ndarray/base/descriptor], followed by any additional ndarray arguments. +- **views**: initialized ndarray [descriptors][@stdlib/ndarray/base/descriptor] representing subarray views. +- **shape**: loop dimensions. Should have seven elements. +- **stridesX**: loop dimension strides for the first input ndarray. +- **stridesY**: loop dimension strides for the second input ndarray. +- **stridesZ**: loop dimension strides for the output ndarray. +- **strategyX**: strategy for marshaling data to and from a first input ndarray view. +- **strategyY**: strategy for marshaling data to and from a second input ndarray view. +- **strategyZ**: strategy for marshaling data to and from an output ndarray view. +- **options**: function options which are passed through to `fcn`. + + + +#### kernel.kernel.kernel8d( fcn, arrays, views, shape, stridesX, strideY, strideZ, strategyX, strategyY, strategyZ, options ) + + + +Applies a one-dimensional strided array function to a list of specified dimensions in two input ndarrays and assigns results to a provided output ndarray. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var gwxpy = require( '@stdlib/blas/ext/base/ndarray/gwxpy' ); + +// 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( [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0 ] ); +var zbuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + +// Define the array shapes: +var xsh = [ 1, 1, 1, 1, 1, 1, 1, 3, 2, 2 ]; +var ysh = [ 1, 1, 1, 1, 1, 1, 1, 3, 2, 2 ]; +var zsh = [ 1, 1, 1, 1, 1, 1, 1, 3, 2, 2 ]; + +// Define the array strides: +var sx = [ 12, 12, 12, 12, 12, 12, 12, 4, 2, 1 ]; +var sy = [ 12, 12, 12, 12, 12, 12, 12, 4, 2, 1 ]; +var sz = [ 12, 12, 12, 12, 12, 12, 12, 4, 2, 1 ]; + +// Define the index offsets: +var ox = 0; +var oy = 0; +var oz = 0; + +// Create the input ndarray descriptors: +var x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': xsh, + 'strides': sx, + 'offset': ox, + 'order': 'row-major' +}; + +var y = { + 'dtype': 'float64', + 'data': ybuf, + 'shape': ysh, + 'strides': sy, + 'offset': oy, + 'order': 'row-major' +}; + +// Create an output ndarray descriptor: +var z = { + 'dtype': 'float64', + 'data': zbuf, + 'shape': zsh, + 'strides': sz, + 'offset': oz, + 'order': 'row-major' +}; + +// Initialize ndarray descriptors representing subarray views: +var views = [ + { + 'dtype': x.dtype, + 'data': x.data, + 'shape': [ 2, 2 ], + 'strides': [ 2, 1 ], + 'offset': x.offset, + 'order': x.order + }, + { + 'dtype': y.dtype, + 'data': y.data, + 'shape': [ 2, 2 ], + 'strides': [ 2, 1 ], + 'offset': y.offset, + 'order': y.order + }, + { + 'dtype': z.dtype, + 'data': z.data, + 'shape': [ 2, 2 ], + 'strides': [ 2, 1 ], + 'offset': z.offset, + 'order': z.order + } +]; + +// Define an input strategy: +function inputStrategy( x ) { + return { + 'dtype': x.dtype, + 'data': x.data, + 'shape': [ 4 ], + 'strides': [ 1 ], + 'offset': x.offset, + 'order': x.order + }; +} + +// Define an output strategy: +function outputStrategy( x ) { + return x; +} + +var strategy = { + 'input': inputStrategy, + 'output': outputStrategy +}; + +// Apply strided function: +kernel.kernel8d( gwxpy, [ x, y, z ], views, [ 1, 1, 1, 1, 1, 1, 1, 3 ], [ 12, 12, 12, 12, 12, 12, 12, 4 ], [ 12, 12, 12, 12, 12, 12, 12, 4 ], [ 12, 12, 12, 12, 12, 12, 12, 4 ], strategy, strategy, strategy, {} ); + +var arr = ndarray2array( z.data, z.shape, z.strides, z.offset, z.order ); +// returns [ [ [ [ [ [ [ [ [ [ 3.0, 5.0 ], [ 7.0, 9.0 ] ], [ [ 11.0, 13.0 ], [ 15.0, 17.0 ] ], [ [ 19.0, 21.0 ], [ 23.0, 25.0 ] ] ] ] ] ] ] ] ] ] +``` + +The function has the following parameters: + +- **fcn**: function which will be applied to two one-dimensional input subarrays and should update a one-dimensional output subarray with results. +- **arrays**: array containing two input ndarray [descriptors][@stdlib/ndarray/base/descriptor] and one output ndarray [descriptor][@stdlib/ndarray/base/descriptor], followed by any additional ndarray arguments. +- **views**: initialized ndarray [descriptors][@stdlib/ndarray/base/descriptor] representing subarray views. +- **shape**: loop dimensions. Should have eight elements. +- **stridesX**: loop dimension strides for the first input ndarray. +- **stridesY**: loop dimension strides for the second input ndarray. +- **stridesZ**: loop dimension strides for the output ndarray. +- **strategyX**: strategy for marshaling data to and from a first input ndarray view. +- **strategyY**: strategy for marshaling data to and from a second input ndarray view. +- **strategyZ**: strategy for marshaling data to and from an output ndarray view. +- **options**: function options which are passed through to `fcn`. + + + +#### kernel.kernel.kernel9d( fcn, arrays, views, shape, stridesX, strideY, strideZ, strategyX, strategyY, strategyZ, options ) + + + +Applies a one-dimensional strided array function to a list of specified dimensions in two input ndarrays and assigns results to a provided output ndarray. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var gwxpy = require( '@stdlib/blas/ext/base/ndarray/gwxpy' ); + +// 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( [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0 ] ); +var zbuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + +// Define the array shapes: +var xsh = [ 1, 1, 1, 1, 1, 1, 1, 1, 3, 2, 2 ]; +var ysh = [ 1, 1, 1, 1, 1, 1, 1, 1, 3, 2, 2 ]; +var zsh = [ 1, 1, 1, 1, 1, 1, 1, 1, 3, 2, 2 ]; + +// Define the array strides: +var sx = [ 12, 12, 12, 12, 12, 12, 12, 12, 4, 2, 1 ]; +var sy = [ 12, 12, 12, 12, 12, 12, 12, 12, 4, 2, 1 ]; +var sz = [ 12, 12, 12, 12, 12, 12, 12, 12, 4, 2, 1 ]; + +// Define the index offsets: +var ox = 0; +var oy = 0; +var oz = 0; + +// Create the input ndarray descriptors: +var x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': xsh, + 'strides': sx, + 'offset': ox, + 'order': 'row-major' +}; + +var y = { + 'dtype': 'float64', + 'data': ybuf, + 'shape': ysh, + 'strides': sy, + 'offset': oy, + 'order': 'row-major' +}; + +// Create an output ndarray descriptor: +var z = { + 'dtype': 'float64', + 'data': zbuf, + 'shape': zsh, + 'strides': sz, + 'offset': oz, + 'order': 'row-major' +}; + +// Initialize ndarray descriptors representing subarray views: +var views = [ + { + 'dtype': x.dtype, + 'data': x.data, + 'shape': [ 2, 2 ], + 'strides': [ 2, 1 ], + 'offset': x.offset, + 'order': x.order + }, + { + 'dtype': y.dtype, + 'data': y.data, + 'shape': [ 2, 2 ], + 'strides': [ 2, 1 ], + 'offset': y.offset, + 'order': y.order + }, + { + 'dtype': z.dtype, + 'data': z.data, + 'shape': [ 2, 2 ], + 'strides': [ 2, 1 ], + 'offset': z.offset, + 'order': z.order + } +]; + +// Define an input strategy: +function inputStrategy( x ) { + return { + 'dtype': x.dtype, + 'data': x.data, + 'shape': [ 4 ], + 'strides': [ 1 ], + 'offset': x.offset, + 'order': x.order + }; +} + +// Define an output strategy: +function outputStrategy( x ) { + return x; +} + +var strategy = { + 'input': inputStrategy, + 'output': outputStrategy +}; + +// Apply strided function: +kernel.kernel9d( gwxpy, [ x, y, z ], views, [ 1, 1, 1, 1, 1, 1, 1, 1, 3 ], [ 12, 12, 12, 12, 12, 12, 12, 12, 4 ], [ 12, 12, 12, 12, 12, 12, 12, 12, 4 ], [ 12, 12, 12, 12, 12, 12, 12, 12, 4 ], strategy, strategy, strategy, {} ); + +var arr = ndarray2array( z.data, z.shape, z.strides, z.offset, z.order ); +// returns [ [ [ [ [ [ [ [ [ [ [ 3.0, 5.0 ], [ 7.0, 9.0 ] ], [ [ 11.0, 13.0 ], [ 15.0, 17.0 ] ], [ [ 19.0, 21.0 ], [ 23.0, 25.0 ] ] ] ] ] ] ] ] ] ] ] +``` + +The function has the following parameters: + +- **fcn**: function which will be applied to two one-dimensional input subarrays and should update a one-dimensional output subarray with results. +- **arrays**: array containing two input ndarray [descriptors][@stdlib/ndarray/base/descriptor] and one output ndarray [descriptor][@stdlib/ndarray/base/descriptor], followed by any additional ndarray arguments. +- **views**: initialized ndarray [descriptors][@stdlib/ndarray/base/descriptor] representing subarray views. +- **shape**: loop dimensions. Should have nine elements. +- **stridesX**: loop dimension strides for the first input ndarray. +- **stridesY**: loop dimension strides for the second input ndarray. +- **stridesZ**: loop dimension strides for the output ndarray. +- **strategyX**: strategy for marshaling data to and from a first input ndarray view. +- **strategyY**: strategy for marshaling data to and from a second input ndarray view. +- **strategyZ**: strategy for marshaling data to and from an output ndarray view. +- **options**: function options which are passed through to `fcn`. + + + +#### kernel.kernel.kernel10d( fcn, arrays, views, shape, stridesX, strideY, strideZ, strategyX, strategyY, strategyZ, options ) + + + +Applies a one-dimensional strided array function to a list of specified dimensions in two input ndarrays and assigns results to a provided output ndarray. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var gwxpy = require( '@stdlib/blas/ext/base/ndarray/gwxpy' ); + +// 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( [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0 ] ); +var zbuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + +// Define the array shapes: +var xsh = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 2, 2 ]; +var ysh = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 2, 2 ]; +var zsh = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 2, 2 ]; + +// Define the array strides: +var sx = [ 12, 12, 12, 12, 12, 12, 12, 12, 12, 4, 2, 1 ]; +var sy = [ 12, 12, 12, 12, 12, 12, 12, 12, 12, 4, 2, 1 ]; +var sz = [ 12, 12, 12, 12, 12, 12, 12, 12, 12, 4, 2, 1 ]; + +// Define the index offsets: +var ox = 0; +var oy = 0; +var oz = 0; + +// Create the input ndarray descriptors: +var x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': xsh, + 'strides': sx, + 'offset': ox, + 'order': 'row-major' +}; + +var y = { + 'dtype': 'float64', + 'data': ybuf, + 'shape': ysh, + 'strides': sy, + 'offset': oy, + 'order': 'row-major' +}; + +// Create an output ndarray descriptor: +var z = { + 'dtype': 'float64', + 'data': zbuf, + 'shape': zsh, + 'strides': sz, + 'offset': oz, + 'order': 'row-major' +}; + +// Initialize ndarray descriptors representing subarray views: +var views = [ + { + 'dtype': x.dtype, + 'data': x.data, + 'shape': [ 2, 2 ], + 'strides': [ 2, 1 ], + 'offset': x.offset, + 'order': x.order + }, + { + 'dtype': y.dtype, + 'data': y.data, + 'shape': [ 2, 2 ], + 'strides': [ 2, 1 ], + 'offset': y.offset, + 'order': y.order + }, + { + 'dtype': z.dtype, + 'data': z.data, + 'shape': [ 2, 2 ], + 'strides': [ 2, 1 ], + 'offset': z.offset, + 'order': z.order + } +]; + +// Define an input strategy: +function inputStrategy( x ) { + return { + 'dtype': x.dtype, + 'data': x.data, + 'shape': [ 4 ], + 'strides': [ 1 ], + 'offset': x.offset, + 'order': x.order + }; +} + +// Define an output strategy: +function outputStrategy( x ) { + return x; +} + +var strategy = { + 'input': inputStrategy, + 'output': outputStrategy +}; + +// Apply strided function: +kernel.kernel10d( gwxpy, [ x, y, z ], views, [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 3 ], [ 12, 12, 12, 12, 12, 12, 12, 12, 12, 4 ], [ 12, 12, 12, 12, 12, 12, 12, 12, 12, 4 ], [ 12, 12, 12, 12, 12, 12, 12, 12, 12, 4 ], strategy, strategy, strategy, {} ); + +var arr = ndarray2array( z.data, z.shape, z.strides, z.offset, z.order ); +// returns [ [ [ [ [ [ [ [ [ [ [ [ 3.0, 5.0 ], [ 7.0, 9.0 ] ], [ [ 11.0, 13.0 ], [ 15.0, 17.0 ] ], [ [ 19.0, 21.0 ], [ 23.0, 25.0 ] ] ] ] ] ] ] ] ] ] ] ] +``` + +The function has the following parameters: + +- **fcn**: function which will be applied to two one-dimensional input subarrays and should update a one-dimensional output subarray with results. +- **arrays**: array containing two input ndarray [descriptors][@stdlib/ndarray/base/descriptor] and one output ndarray [descriptor][@stdlib/ndarray/base/descriptor], followed by any additional ndarray arguments. +- **views**: initialized ndarray [descriptors][@stdlib/ndarray/base/descriptor] representing subarray views. +- **shape**: loop dimensions. Should have ten elements. +- **stridesX**: loop dimension strides for the first input ndarray. +- **stridesY**: loop dimension strides for the second input ndarray. +- **stridesZ**: loop dimension strides for the output ndarray. +- **strategyX**: strategy for marshaling data to and from a first input ndarray view. +- **strategyY**: strategy for marshaling data to and from a second input ndarray view. +- **strategyZ**: strategy for marshaling data to and from an output ndarray view. +- **options**: function options which are passed through to `fcn`. + +
+ + + +
+ +## Notes + +- The strided array function is expected to have the following signature: + + ```text + fcn( arrays[, options] ) + ``` + + where + + - **arrays**: array containing a one-dimensional subarray of the first input ndarray, a one-dimensional subarray of the second input ndarray, a one-dimensional subarray of the output ndarray, and any additional ndarray arguments as subarrays. + - **options**: function options (_optional_). + +
+ + + +
+ +## Examples + + + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var gwxpy = require( '@stdlib/blas/ext/base/ndarray/gwxpy' ); +var strategy = require( '@stdlib/ndarray/base/kernels/generic/unary-strided1d/strategy' ); +var kernel = require( '@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked' ); + +// 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( [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0 ] ); +var zbuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + +// Define the array shapes: +var xsh = [ 1, 1, 1, 1, 3, 2, 2 ]; +var ysh = [ 1, 1, 1, 1, 3, 2, 2 ]; +var zsh = [ 1, 1, 1, 1, 3, 2, 2 ]; + +// Define the array strides: +var sx = [ 12, 12, 12, 12, 4, 2, 1 ]; +var sy = [ 12, 12, 12, 12, 4, 2, 1 ]; +var sz = [ 12, 12, 12, 12, 4, 2, 1 ]; + +// Define the index offsets: +var ox = 0; +var oy = 0; +var oz = 0; + +// Create the input ndarray descriptors: +var x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': xsh, + 'strides': sx, + 'offset': ox, + 'order': 'row-major' +}; + +var y = { + 'dtype': 'float64', + 'data': ybuf, + 'shape': ysh, + 'strides': sy, + 'offset': oy, + 'order': 'row-major' +}; + +// Create an output ndarray descriptor: +var z = { + 'dtype': 'float64', + 'data': zbuf, + 'shape': zsh, + 'strides': sz, + 'offset': oz, + 'order': 'row-major' +}; + +// Initialize ndarray descriptors representing subarray views: +var views = [ + { + 'dtype': x.dtype, + 'data': x.data, + 'shape': [ 2, 2 ], + 'strides': [ 2, 1 ], + 'offset': x.offset, + 'order': x.order + }, + { + 'dtype': y.dtype, + 'data': y.data, + 'shape': [ 2, 2 ], + 'strides': [ 2, 1 ], + 'offset': y.offset, + 'order': y.order + }, + { + 'dtype': z.dtype, + 'data': z.data, + 'shape': [ 2, 2 ], + 'strides': [ 2, 1 ], + 'offset': z.offset, + 'order': z.order + } +]; + +// Resolve input/output strategies when iterating over subarray views: +var strategyX = strategy( views[ 0 ] ); +var strategyY = strategy( views[ 1 ] ); +var strategyZ = strategy( views[ 2 ] ); + +// Resolve a kernel: +var f = kernel( 5 ); + +// Apply strided function: +f( gwxpy, [ x, y, z ], views, [ 1, 1, 1, 1, 3 ], [ 12, 12, 12, 12, 4 ], [ 12, 12, 12, 12, 4 ], [ 12, 12, 12, 12, 4 ], strategyX, strategyY, strategyZ, {} ); + +console.log( ndarray2array( x.data, x.shape, x.strides, x.offset, x.order ) ); +console.log( ndarray2array( y.data, y.shape, y.strides, y.offset, y.order ) ); +console.log( ndarray2array( z.data, z.shape, z.strides, z.offset, z.order ) ); +``` + +
+ + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/docs/repl.txt new file mode 100644 index 000000000000..ef8d785a8002 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/docs/repl.txt @@ -0,0 +1,510 @@ +{{alias}}( ndims ) + Returns a kernel for applying a one-dimensional strided array function to + two input ndarrays and assigning results to an output ndarray. + + The returned function has the following parameters: + + - fcn: function which will be applied to two one-dimensional input + subarrays and should update a one-dimensional output subarray with results. + - arrays: array containing two input ndarray descriptors and one output + ndarray descriptor, followed by any additional ndarray arguments. + - views: initialized ndarray descriptors representing subarray views. + - shape: loop dimensions. + - stridesX: loop dimension strides for the first input ndarray. + - stridesY: loop dimension strides for the second input ndarray. + - stridesZ: loop dimension strides for the output ndarray. + - strategyX: strategy for marshaling data to and from a first input ndarray + view. + - strategyY: strategy for marshaling data to and from a second input ndarray + view. + - strategyZ: strategy for marshaling data to and from an output ndarray + view. + - options: function options which are passed through to `fcn`. + + If `ndims` is greater than the maximum supported number of loop dimensions, + the function returns `null`. + + Parameters + ---------- + ndims: integer + Number of loop dimensions. + + Returns + ------- + fcn: Function|null + Kernel function. + + Examples + -------- + > var f = {{alias}}( 2 ) + + + +{{alias}}.kernel0d( fcn, arr, views, sh, sx, sy, sz, stX, stY, stZ, opts ) + Applies a one-dimensional strided array function to a list of specified + dimensions in two input ndarrays and assigns results to a provided output + ndarray. + + The `views`, `sh`, `sx`, `sy`, and `sz` parameters are unused. Providing + empty arrays for these parameters is recommended in order to ensure a + monomorphic API. + + Parameters + ---------- + fcn: Function + Wrapper for a one-dimensional strided array function. + + arr: Array + Array containing two input ndarray descriptors and one output ndarray + descriptor, followed by any additional ndarray arguments. + + views: Array + Initialized ndarray descriptors representing subarray views. + + sh: Array + Loop dimensions. Should have zero elements. + + sx: Array + Loop dimension strides for the first input ndarray. + + sy: Array + Loop dimension strides for the second input ndarray. + + sz: Array + Loop dimension strides for the output ndarray. + + stX: Object + Strategy for marshaling data to and from a first input ndarray view. + + stY: Object + Strategy for marshaling data to and from a second input ndarray view. + + stZ: Object + Strategy for marshaling data to and from an output ndarray view. + + opts: Object + Function options which are passed through to `fcn`. + + +{{alias}}.kernel1d( fcn, arr, views, sh, sx, sy, sz, stX, stY, stZ, opts ) + Applies a one-dimensional strided array function to a list of specified + dimensions in two input ndarrays and assigns results to a provided output + ndarray. + + Parameters + ---------- + fcn: Function + Wrapper for a one-dimensional strided array function. + + arr: Array + Array containing two input ndarray descriptors and one output ndarray + descriptor, followed by any additional ndarray arguments. + + views: Array + Initialized ndarray descriptors representing subarray views. + + sh: Array + Loop dimensions. Should have one element. + + sx: Array + Loop dimension strides for the first input ndarray. + + sy: Array + Loop dimension strides for the second input ndarray. + + sz: Array + Loop dimension strides for the output ndarray. + + stX: Object + Strategy for marshaling data to and from a first input ndarray view. + + stY: Object + Strategy for marshaling data to and from a second input ndarray view. + + stZ: Object + Strategy for marshaling data to and from an output ndarray view. + + opts: Object + Function options which are passed through to `fcn`. + + +{{alias}}.kernel2d( fcn, arr, views, sh, sx, sy, sz, stX, stY, stZ, opts ) + Applies a one-dimensional strided array function to a list of specified + dimensions in two input ndarrays and assigns results to a provided output + ndarray. + + Parameters + ---------- + fcn: Function + Wrapper for a one-dimensional strided array function. + + arr: Array + Array containing two input ndarray descriptors and one output ndarray + descriptor, followed by any additional ndarray arguments. + + views: Array + Initialized ndarray descriptors representing subarray views. + + sh: Array + Loop dimensions. Should have two elements. + + sx: Array + Loop dimension strides for the first input ndarray. + + sy: Array + Loop dimension strides for the second input ndarray. + + sz: Array + Loop dimension strides for the output ndarray. + + stX: Object + Strategy for marshaling data to and from a first input ndarray view. + + stY: Object + Strategy for marshaling data to and from a second input ndarray view. + + stZ: Object + Strategy for marshaling data to and from an output ndarray view. + + opts: Object + Function options which are passed through to `fcn`. + + +{{alias}}.kernel3d( fcn, arr, views, sh, sx, sy, sz, stX, stY, stZ, opts ) + Applies a one-dimensional strided array function to a list of specified + dimensions in two input ndarrays and assigns results to a provided output + ndarray. + + Parameters + ---------- + fcn: Function + Wrapper for a one-dimensional strided array function. + + arr: Array + Array containing two input ndarray descriptors and one output ndarray + descriptor, followed by any additional ndarray arguments. + + views: Array + Initialized ndarray descriptors representing subarray views. + + sh: Array + Loop dimensions. Should have three elements. + + sx: Array + Loop dimension strides for the first input ndarray. + + sy: Array + Loop dimension strides for the second input ndarray. + + sz: Array + Loop dimension strides for the output ndarray. + + stX: Object + Strategy for marshaling data to and from a first input ndarray view. + + stY: Object + Strategy for marshaling data to and from a second input ndarray view. + + stZ: Object + Strategy for marshaling data to and from an output ndarray view. + + opts: Object + Function options which are passed through to `fcn`. + + +{{alias}}.kernel4d( fcn, arr, views, sh, sx, sy, sz, stX, stY, stZ, opts ) + Applies a one-dimensional strided array function to a list of specified + dimensions in two input ndarrays and assigns results to a provided output + ndarray. + + Parameters + ---------- + fcn: Function + Wrapper for a one-dimensional strided array function. + + arr: Array + Array containing two input ndarray descriptors and one output ndarray + descriptor, followed by any additional ndarray arguments. + + views: Array + Initialized ndarray descriptors representing subarray views. + + sh: Array + Loop dimensions. Should have four elements. + + sx: Array + Loop dimension strides for the first input ndarray. + + sy: Array + Loop dimension strides for the second input ndarray. + + sz: Array + Loop dimension strides for the output ndarray. + + stX: Object + Strategy for marshaling data to and from a first input ndarray view. + + stY: Object + Strategy for marshaling data to and from a second input ndarray view. + + stZ: Object + Strategy for marshaling data to and from an output ndarray view. + + opts: Object + Function options which are passed through to `fcn`. + + +{{alias}}.kernel5d( fcn, arr, views, sh, sx, sy, sz, stX, stY, stZ, opts ) + Applies a one-dimensional strided array function to a list of specified + dimensions in two input ndarrays and assigns results to a provided output + ndarray. + + Parameters + ---------- + fcn: Function + Wrapper for a one-dimensional strided array function. + + arr: Array + Array containing two input ndarray descriptors and one output ndarray + descriptor, followed by any additional ndarray arguments. + + views: Array + Initialized ndarray descriptors representing subarray views. + + sh: Array + Loop dimensions. Should have five elements. + + sx: Array + Loop dimension strides for the first input ndarray. + + sy: Array + Loop dimension strides for the second input ndarray. + + sz: Array + Loop dimension strides for the output ndarray. + + stX: Object + Strategy for marshaling data to and from a first input ndarray view. + + stY: Object + Strategy for marshaling data to and from a second input ndarray view. + + stZ: Object + Strategy for marshaling data to and from an output ndarray view. + + opts: Object + Function options which are passed through to `fcn`. + + +{{alias}}.kernel6d( fcn, arr, views, sh, sx, sy, sz, stX, stY, stZ, opts ) + Applies a one-dimensional strided array function to a list of specified + dimensions in two input ndarrays and assigns results to a provided output + ndarray. + + Parameters + ---------- + fcn: Function + Wrapper for a one-dimensional strided array function. + + arr: Array + Array containing two input ndarray descriptors and one output ndarray + descriptor, followed by any additional ndarray arguments. + + views: Array + Initialized ndarray descriptors representing subarray views. + + sh: Array + Loop dimensions. Should have six elements. + + sx: Array + Loop dimension strides for the first input ndarray. + + sy: Array + Loop dimension strides for the second input ndarray. + + sz: Array + Loop dimension strides for the output ndarray. + + stX: Object + Strategy for marshaling data to and from a first input ndarray view. + + stY: Object + Strategy for marshaling data to and from a second input ndarray view. + + stZ: Object + Strategy for marshaling data to and from an output ndarray view. + + opts: Object + Function options which are passed through to `fcn`. + + +{{alias}}.kernel7d( fcn, arr, views, sh, sx, sy, sz, stX, stY, stZ, opts ) + Applies a one-dimensional strided array function to a list of specified + dimensions in two input ndarrays and assigns results to a provided output + ndarray. + + Parameters + ---------- + fcn: Function + Wrapper for a one-dimensional strided array function. + + arr: Array + Array containing two input ndarray descriptors and one output ndarray + descriptor, followed by any additional ndarray arguments. + + views: Array + Initialized ndarray descriptors representing subarray views. + + sh: Array + Loop dimensions. Should have seven elements. + + sx: Array + Loop dimension strides for the first input ndarray. + + sy: Array + Loop dimension strides for the second input ndarray. + + sz: Array + Loop dimension strides for the output ndarray. + + stX: Object + Strategy for marshaling data to and from a first input ndarray view. + + stY: Object + Strategy for marshaling data to and from a second input ndarray view. + + stZ: Object + Strategy for marshaling data to and from an output ndarray view. + + opts: Object + Function options which are passed through to `fcn`. + + +{{alias}}.kernel8d( fcn, arr, views, sh, sx, sy, sz, stX, stY, stZ, opts ) + Applies a one-dimensional strided array function to a list of specified + dimensions in two input ndarrays and assigns results to a provided output + ndarray. + + Parameters + ---------- + fcn: Function + Wrapper for a one-dimensional strided array function. + + arr: Array + Array containing two input ndarray descriptors and one output ndarray + descriptor, followed by any additional ndarray arguments. + + views: Array + Initialized ndarray descriptors representing subarray views. + + sh: Array + Loop dimensions. Should have eight elements. + + sx: Array + Loop dimension strides for the first input ndarray. + + sy: Array + Loop dimension strides for the second input ndarray. + + sz: Array + Loop dimension strides for the output ndarray. + + stX: Object + Strategy for marshaling data to and from a first input ndarray view. + + stY: Object + Strategy for marshaling data to and from a second input ndarray view. + + stZ: Object + Strategy for marshaling data to and from an output ndarray view. + + opts: Object + Function options which are passed through to `fcn`. + + +{{alias}}.kernel9d( fcn, arr, views, sh, sx, sy, sz, stX, stY, stZ, opts ) + Applies a one-dimensional strided array function to a list of specified + dimensions in two input ndarrays and assigns results to a provided output + ndarray. + + Parameters + ---------- + fcn: Function + Wrapper for a one-dimensional strided array function. + + arr: Array + Array containing two input ndarray descriptors and one output ndarray + descriptor, followed by any additional ndarray arguments. + + views: Array + Initialized ndarray descriptors representing subarray views. + + sh: Array + Loop dimensions. Should have nine elements. + + sx: Array + Loop dimension strides for the first input ndarray. + + sy: Array + Loop dimension strides for the second input ndarray. + + sz: Array + Loop dimension strides for the output ndarray. + + stX: Object + Strategy for marshaling data to and from a first input ndarray view. + + stY: Object + Strategy for marshaling data to and from a second input ndarray view. + + stZ: Object + Strategy for marshaling data to and from an output ndarray view. + + opts: Object + Function options which are passed through to `fcn`. + + +{{alias}}.kernel10d( fcn, arr, views, sh, sx, sy, sz, stX, stY, stZ, opts ) + Applies a one-dimensional strided array function to a list of specified + dimensions in two input ndarrays and assigns results to a provided output + ndarray. + + Parameters + ---------- + fcn: Function + Wrapper for a one-dimensional strided array function. + + arr: Array + Array containing two input ndarray descriptors and one output ndarray + descriptor, followed by any additional ndarray arguments. + + views: Array + Initialized ndarray descriptors representing subarray views. + + sh: Array + Loop dimensions. Should have ten elements. + + sx: Array + Loop dimension strides for the first input ndarray. + + sy: Array + Loop dimension strides for the second input ndarray. + + sz: Array + Loop dimension strides for the output ndarray. + + stX: Object + Strategy for marshaling data to and from a first input ndarray view. + + stY: Object + Strategy for marshaling data to and from a second input ndarray view. + + stZ: Object + Strategy for marshaling data to and from an output ndarray view. + + opts: Object + Function options which are passed through to `fcn`. + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/examples/index.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/examples/index.js new file mode 100644 index 000000000000..62a43de2234c --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/examples/index.js @@ -0,0 +1,119 @@ +/** +* @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-len */ + +'use strict'; + +var Float64Array = require( '@stdlib/array/float64' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var gwxpy = require( '@stdlib/blas/ext/base/ndarray/gwxpy' ); +var strategy = require( '@stdlib/ndarray/base/kernels/generic/unary-strided1d/strategy' ); +var kernel = require( './../lib' ); + +// 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( [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0 ] ); +var zbuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + +// Define the array shapes: +var xsh = [ 1, 1, 1, 1, 3, 2, 2 ]; +var ysh = [ 1, 1, 1, 1, 3, 2, 2 ]; +var zsh = [ 1, 1, 1, 1, 3, 2, 2 ]; + +// Define the array strides: +var sx = [ 12, 12, 12, 12, 4, 2, 1 ]; +var sy = [ 12, 12, 12, 12, 4, 2, 1 ]; +var sz = [ 12, 12, 12, 12, 4, 2, 1 ]; + +// Define the index offsets: +var ox = 0; +var oy = 0; +var oz = 0; + +// Create the input ndarray descriptors: +var x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': xsh, + 'strides': sx, + 'offset': ox, + 'order': 'row-major' +}; + +var y = { + 'dtype': 'float64', + 'data': ybuf, + 'shape': ysh, + 'strides': sy, + 'offset': oy, + 'order': 'row-major' +}; + +// Create an output ndarray descriptor: +var z = { + 'dtype': 'float64', + 'data': zbuf, + 'shape': zsh, + 'strides': sz, + 'offset': oz, + 'order': 'row-major' +}; + +// Initialize ndarray descriptors representing subarray views: +var views = [ + { + 'dtype': x.dtype, + 'data': x.data, + 'shape': [ 2, 2 ], + 'strides': [ 2, 1 ], + 'offset': x.offset, + 'order': x.order + }, + { + 'dtype': y.dtype, + 'data': y.data, + 'shape': [ 2, 2 ], + 'strides': [ 2, 1 ], + 'offset': y.offset, + 'order': y.order + }, + { + 'dtype': z.dtype, + 'data': z.data, + 'shape': [ 2, 2 ], + 'strides': [ 2, 1 ], + 'offset': z.offset, + 'order': z.order + } +]; + +// Resolve input/output strategies when iterating over subarray views: +var strategyX = strategy( views[ 0 ] ); +var strategyY = strategy( views[ 1 ] ); +var strategyZ = strategy( views[ 2 ] ); + +// Resolve a kernel: +var f = kernel( 5 ); + +// Apply strided function: +f( gwxpy, [ x, y, z ], views, [ 1, 1, 1, 1, 3 ], [ 12, 12, 12, 12, 4 ], [ 12, 12, 12, 12, 4 ], [ 12, 12, 12, 12, 4 ], strategyX, strategyY, strategyZ, {} ); + +console.log( ndarray2array( x.data, x.shape, x.strides, x.offset, x.order ) ); +console.log( ndarray2array( y.data, y.shape, y.strides, y.offset, y.order ) ); +console.log( ndarray2array( z.data, z.shape, z.strides, z.offset, z.order ) ); diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/0d.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/0d.js new file mode 100644 index 000000000000..ec56e91e19f3 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/0d.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'; + +// MAIN // + +/** +* Applies a one-dimensional strided array function to a list of specified dimensions in two input ndarrays and assigns results to a provided output ndarray. +* +* ## Notes +* +* - The `views`, `shape`, `stridesX`, `stridesY`, and `stridesZ` parameters are unused. Providing empty arrays for these parameters is recommended in order to ensure a monomorphic API. +* +* @private +* @param {Function} fcn - wrapper for a one-dimensional strided array function +* @param {Array} arrays - ndarray descriptors +* @param {Array} views - initialized ndarray descriptors representing subarray views +* @param {Array} shape - loop dimensions +* @param {Array} stridesX - loop dimension strides for the first input ndarray +* @param {Array} stridesY - loop dimension strides for the second input ndarray +* @param {Array} stridesZ - loop dimension strides for the output ndarray +* @param {Object} strategyX - strategy for marshaling data to and from a first input ndarray view +* @param {Object} strategyY - strategy for marshaling data to and from a second input ndarray view +* @param {Object} strategyZ - strategy for marshaling data to and from an output ndarray view +* @param {Options} opts - function options +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +* var gwxpy = require( '@stdlib/blas/ext/base/ndarray/gwxpy' ); +* +* // Create data buffers: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var ybuf = new Float64Array( [ 2.0, 3.0, 4.0, 5.0 ] ); +* var zbuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); +* +* // Define the array shapes: +* var xsh = [ 2, 2 ]; +* var ysh = [ 2, 2 ]; +* var zsh = [ 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 2, 1 ]; +* var sy = [ 2, 1 ]; +* var sz = [ 2, 1 ]; +* +* // Define the index offsets: +* var ox = 0; +* var oy = 0; +* var oz = 0; +* +* // Create the input ndarray descriptors: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': xsh, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* var y = { +* 'dtype': 'float64', +* 'data': ybuf, +* 'shape': ysh, +* 'strides': sy, +* 'offset': oy, +* 'order': 'row-major' +* }; +* +* // Create an output ndarray descriptor: +* var z = { +* 'dtype': 'float64', +* 'data': zbuf, +* 'shape': zsh, +* 'strides': sz, +* 'offset': oz, +* 'order': 'row-major' +* }; +* +* // Define an input strategy: +* function inputStrategy( x ) { +* return { +* 'dtype': x.dtype, +* 'data': x.data, +* 'shape': [ 4 ], +* 'strides': [ 1 ], +* 'offset': x.offset, +* 'order': x.order +* }; +* } +* +* // Define an output strategy: +* function outputStrategy( x ) { +* return x; +* } +* +* var strategy = { +* 'input': inputStrategy, +* 'output': outputStrategy +* }; +* +* // Apply strided function: +* kernel( gwxpy, [ x, y, z ], [], [], [], [], [], strategy, strategy, strategy, {} ); +* +* var v = z.data; +* // returns [ 3.0, 5.0, 7.0, 9.0 ] +*/ +function kernel( fcn, arrays, views, shape, stridesX, stridesY, stridesZ, strategyX, strategyY, strategyZ, opts ) { // eslint-disable-line max-len, max-params + arrays[ 0 ] = strategyX.input( arrays[ 0 ] ); + arrays[ 1 ] = strategyY.input( arrays[ 1 ] ); + arrays[ 2 ] = strategyZ.input( arrays[ 2 ] ); + fcn( arrays, opts ); + strategyZ.output( arrays[ 2 ] ); +} + + +// EXPORTS // + +module.exports = kernel; diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/10d.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/10d.js new file mode 100644 index 000000000000..1155559498df --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/10d.js @@ -0,0 +1,399 @@ +/** +* @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-depth, max-len */ + +'use strict'; + +// MODULES // + +var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); +var copyIndexed = require( '@stdlib/array/base/copy-indexed' ); +var incrementOffsets = require( '@stdlib/ndarray/base/kernels/utils/increment-offsets' ); +var setViewOffsets = require( '@stdlib/ndarray/base/set-descriptor-offsets' ); +var offsets = require( '@stdlib/ndarray/base/offsets' ); + + +// MAIN // + +/** +* Applies a one-dimensional strided array function to a list of specified dimensions in two input ndarrays and assigns results to a provided output ndarray. +* +* @private +* @param {Function} fcn - wrapper for a one-dimensional strided array function +* @param {Array} arrays - ndarray descriptors +* @param {Array} views - initialized ndarray descriptors representing subarray views +* @param {Array} shape - loop dimensions +* @param {Array} stridesX - loop dimension strides for the first input ndarray +* @param {Array} stridesY - loop dimension strides for the second input ndarray +* @param {Array} stridesZ - loop dimension strides for the output ndarray +* @param {Object} strategyX - strategy for marshaling data to and from a first input ndarray view +* @param {Object} strategyY - strategy for marshaling data to and from a second input ndarray view +* @param {Object} strategyZ - strategy for marshaling data to and from an output ndarray view +* @param {Options} opts - function options +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +* var gwxpy = require( '@stdlib/blas/ext/base/ndarray/gwxpy' ); +* +* // 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( [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0 ] ); +* var zbuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* // Define the array shapes: +* var xsh = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 2, 2 ]; +* var ysh = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 2, 2 ]; +* var zsh = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 12, 12, 12, 12, 12, 12, 12, 12, 12, 4, 2, 1 ]; +* var sy = [ 12, 12, 12, 12, 12, 12, 12, 12, 12, 4, 2, 1 ]; +* var sz = [ 12, 12, 12, 12, 12, 12, 12, 12, 12, 4, 2, 1 ]; +* +* // Define the index offsets: +* var ox = 0; +* var oy = 0; +* var oz = 0; +* +* // Create the input ndarray descriptors: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': xsh, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* var y = { +* 'dtype': 'float64', +* 'data': ybuf, +* 'shape': ysh, +* 'strides': sy, +* 'offset': oy, +* 'order': 'row-major' +* }; +* +* // Create an output ndarray descriptor: +* var z = { +* 'dtype': 'float64', +* 'data': zbuf, +* 'shape': zsh, +* 'strides': sz, +* 'offset': oz, +* 'order': 'row-major' +* }; +* +* // Initialize ndarray descriptors representing subarray views: +* var views = [ +* { +* 'dtype': x.dtype, +* 'data': x.data, +* 'shape': [ 2, 2 ], +* 'strides': [ 2, 1 ], +* 'offset': x.offset, +* 'order': x.order +* }, +* { +* 'dtype': y.dtype, +* 'data': y.data, +* 'shape': [ 2, 2 ], +* 'strides': [ 2, 1 ], +* 'offset': y.offset, +* 'order': y.order +* }, +* { +* 'dtype': z.dtype, +* 'data': z.data, +* 'shape': [ 2, 2 ], +* 'strides': [ 2, 1 ], +* 'offset': z.offset, +* 'order': z.order +* } +* ]; +* +* // Define an input strategy: +* function inputStrategy( x ) { +* return { +* 'dtype': x.dtype, +* 'data': x.data, +* 'shape': [ 4 ], +* 'strides': [ 1 ], +* 'offset': x.offset, +* 'order': x.order +* }; +* } +* +* // Define an output strategy: +* function outputStrategy( x ) { +* return x; +* } +* +* var strategy = { +* 'input': inputStrategy, +* 'output': outputStrategy +* }; +* +* // Apply strided function: +* kernel( gwxpy, [ x, y, z ], views, [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 3 ], [ 12, 12, 12, 12, 12, 12, 12, 12, 12, 4 ], [ 12, 12, 12, 12, 12, 12, 12, 12, 12, 4 ], [ 12, 12, 12, 12, 12, 12, 12, 12, 12, 4 ], strategy, strategy, strategy, {} ); +* +* var arr = ndarray2array( z.data, z.shape, z.strides, z.offset, z.order ); +* // returns [ [ [ [ [ [ [ [ [ [ [ [ 3.0, 5.0 ], [ 7.0, 9.0 ] ], [ [ 11.0, 13.0 ], [ 15.0, 17.0 ] ], [ [ 19.0, 21.0 ], [ 23.0, 25.0 ] ] ] ] ] ] ] ] ] ] ] ] +*/ +function kernel( fcn, arrays, views, shape, stridesX, stridesY, stridesZ, strategyX, strategyY, strategyZ, opts ) { // eslint-disable-line max-params, max-statements, max-lines-per-function + var dv0; + var dv1; + var dv2; + var dv3; + var dv4; + var dv5; + var dv6; + var dv7; + var dv8; + var dv9; + var S0; + var S1; + var S2; + var S3; + var S4; + var S5; + var S6; + var S7; + var S8; + var S9; + var sv; + var iv; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + var i7; + var i8; + var i9; + var v; + var i; + + // Note on variable naming convention: S#, dv#, 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... + if ( isRowMajor( stridesX ) ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = shape[ 9 ]; + S1 = shape[ 8 ]; + S2 = shape[ 7 ]; + S3 = shape[ 6 ]; + S4 = shape[ 5 ]; + S5 = shape[ 4 ]; + S6 = shape[ 3 ]; + S7 = shape[ 2 ]; + S8 = shape[ 1 ]; + S9 = shape[ 0 ]; + dv0 = [ // offset increment for innermost loop + stridesX[9], + stridesY[9], + stridesZ[9] + ]; + dv1 = [ + stridesX[8] - ( S0*stridesX[9] ), + stridesY[8] - ( S0*stridesY[9] ), + stridesZ[8] - ( S0*stridesZ[9] ) + ]; + dv2 = [ + stridesX[7] - ( S1*stridesX[8] ), + stridesY[7] - ( S1*stridesY[8] ), + stridesZ[7] - ( S1*stridesZ[8] ) + ]; + dv3 = [ + stridesX[6] - ( S2*stridesX[7] ), + stridesY[6] - ( S2*stridesY[7] ), + stridesZ[6] - ( S2*stridesZ[7] ) + ]; + dv4 = [ + stridesX[5] - ( S3*stridesX[6] ), + stridesY[5] - ( S3*stridesY[6] ), + stridesZ[5] - ( S3*stridesZ[6] ) + ]; + dv5 = [ + stridesX[4] - ( S4*stridesX[5] ), + stridesY[4] - ( S4*stridesY[5] ), + stridesZ[4] - ( S4*stridesZ[5] ) + ]; + dv6 = [ + stridesX[3] - ( S5*stridesX[4] ), + stridesY[3] - ( S5*stridesY[4] ), + stridesZ[3] - ( S5*stridesZ[4] ) + ]; + dv7 = [ + stridesX[2] - ( S6*stridesX[3] ), + stridesY[2] - ( S6*stridesY[3] ), + stridesZ[2] - ( S6*stridesZ[3] ) + ]; + dv8 = [ + stridesX[1] - ( S7*stridesX[2] ), + stridesY[1] - ( S7*stridesY[2] ), + stridesZ[1] - ( S7*stridesZ[2] ) + ]; + dv9 = [ // offset increment for outermost loop + stridesX[0] - ( S8*stridesX[1] ), + stridesY[0] - ( S8*stridesY[1] ), + stridesZ[0] - ( S8*stridesZ[1] ) + ]; + for ( i = 3; i < arrays.length; i++ ) { + sv = arrays[ i ].strides; + dv0.push( sv[9] ); + dv1.push( sv[8] - ( S0*sv[9] ) ); + dv2.push( sv[7] - ( S1*sv[8] ) ); + dv3.push( sv[6] - ( S2*sv[7] ) ); + dv4.push( sv[5] - ( S3*sv[6] ) ); + dv5.push( sv[4] - ( S4*sv[5] ) ); + dv6.push( sv[3] - ( S5*sv[4] ) ); + dv7.push( sv[2] - ( S6*sv[3] ) ); + dv8.push( sv[1] - ( S7*sv[2] ) ); + dv9.push( sv[0] - ( S8*sv[1] ) ); + } + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = shape[ 0 ]; + S1 = shape[ 1 ]; + S2 = shape[ 2 ]; + S3 = shape[ 3 ]; + S4 = shape[ 4 ]; + S5 = shape[ 5 ]; + S6 = shape[ 6 ]; + S7 = shape[ 7 ]; + S8 = shape[ 8 ]; + S9 = shape[ 9 ]; + dv0 = [ // offset increment for innermost loop + stridesX[0], + stridesY[0], + stridesZ[0] + ]; + dv1 = [ + stridesX[1] - ( S0*stridesX[0] ), + stridesY[1] - ( S0*stridesY[0] ), + stridesZ[1] - ( S0*stridesZ[0] ) + ]; + dv2 = [ + stridesX[2] - ( S1*stridesX[1] ), + stridesY[2] - ( S1*stridesY[1] ), + stridesZ[2] - ( S1*stridesZ[1] ) + ]; + dv3 = [ + stridesX[3] - ( S2*stridesX[2] ), + stridesY[3] - ( S2*stridesY[2] ), + stridesZ[3] - ( S2*stridesZ[2] ) + ]; + dv4 = [ + stridesX[4] - ( S3*stridesX[3] ), + stridesY[4] - ( S3*stridesY[3] ), + stridesZ[4] - ( S3*stridesZ[3] ) + ]; + dv5 = [ + stridesX[5] - ( S4*stridesX[4] ), + stridesY[5] - ( S4*stridesY[4] ), + stridesZ[5] - ( S4*stridesZ[4] ) + ]; + dv6 = [ + stridesX[6] - ( S5*stridesX[5] ), + stridesY[6] - ( S5*stridesY[5] ), + stridesZ[6] - ( S5*stridesZ[5] ) + ]; + dv7 = [ + stridesX[7] - ( S6*stridesX[6] ), + stridesY[7] - ( S6*stridesY[6] ), + stridesZ[7] - ( S6*stridesZ[6] ) + ]; + dv8 = [ + stridesX[8] - ( S7*stridesX[7] ), + stridesY[8] - ( S7*stridesY[7] ), + stridesZ[8] - ( S7*stridesZ[7] ) + ]; + dv9 = [ // offset increment for outermost loop + stridesX[9] - ( S8*stridesX[8] ), + stridesY[9] - ( S8*stridesY[8] ), + stridesZ[9] - ( S8*stridesZ[8] ) + ]; + for ( i = 3; i < arrays.length; i++ ) { + sv = arrays[ i ].strides; + dv0.push( sv[0] ); + dv1.push( sv[1] - ( S0*sv[0] ) ); + dv2.push( sv[2] - ( S1*sv[1] ) ); + dv3.push( sv[3] - ( S2*sv[2] ) ); + dv4.push( sv[4] - ( S3*sv[3] ) ); + dv5.push( sv[5] - ( S4*sv[4] ) ); + dv6.push( sv[6] - ( S5*sv[5] ) ); + dv7.push( sv[7] - ( S6*sv[6] ) ); + dv8.push( sv[8] - ( S7*sv[7] ) ); + dv9.push( sv[9] - ( S8*sv[8] ) ); + } + } + // Resolve a list of pointers to the first indexed elements in the respective ndarrays: + iv = offsets( arrays ); + + // Shallow copy the list of views to an internal array so that we can update with reshaped views without impacting the original list of views: + v = copyIndexed( views ); + + // Iterate over the loop 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++ ) { + setViewOffsets( views, iv ); + v[ 0 ] = strategyX.input( views[ 0 ] ); + v[ 1 ] = strategyY.input( views[ 1 ] ); + v[ 2 ] = strategyZ.input( views[ 2 ] ); + fcn( v, opts ); + strategyZ.output( views[ 2 ] ); + incrementOffsets( iv, dv0 ); + } + incrementOffsets( iv, dv1 ); + } + incrementOffsets( iv, dv2 ); + } + incrementOffsets( iv, dv3 ); + } + incrementOffsets( iv, dv4 ); + } + incrementOffsets( iv, dv5 ); + } + incrementOffsets( iv, dv6 ); + } + incrementOffsets( iv, dv7 ); + } + incrementOffsets( iv, dv8 ); + } + incrementOffsets( iv, dv9 ); + } +} + + +// EXPORTS // + +module.exports = kernel; diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/1d.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/1d.js new file mode 100644 index 000000000000..9e6176cf1cef --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/1d.js @@ -0,0 +1,199 @@ +/** +* @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 copyIndexed = require( '@stdlib/array/base/copy-indexed' ); +var incrementOffsets = require( '@stdlib/ndarray/base/kernels/utils/increment-offsets' ); +var setViewOffsets = require( '@stdlib/ndarray/base/set-descriptor-offsets' ); +var offsets = require( '@stdlib/ndarray/base/offsets' ); + + +// MAIN // + +/** +* Applies a one-dimensional strided array function to a list of specified dimensions in two input ndarrays and assigns results to a provided output ndarray. +* +* @private +* @param {Function} fcn - wrapper for a one-dimensional strided array function +* @param {Array} arrays - ndarray descriptors +* @param {Array} views - initialized ndarray descriptors representing subarray views +* @param {Array} shape - loop dimensions +* @param {Array} stridesX - loop dimension strides for the first input ndarray +* @param {Array} stridesY - loop dimension strides for the second input ndarray +* @param {Array} stridesZ - loop dimension strides for the output ndarray +* @param {Object} strategyX - strategy for marshaling data to and from a first input ndarray view +* @param {Object} strategyY - strategy for marshaling data to and from a second input ndarray view +* @param {Object} strategyZ - strategy for marshaling data to and from an output ndarray view +* @param {Options} opts - function options +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +* var gwxpy = require( '@stdlib/blas/ext/base/ndarray/gwxpy' ); +* +* // 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( [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0 ] ); +* var zbuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* // Define the array shapes: +* var xsh = [ 3, 2, 2 ]; +* var ysh = [ 3, 2, 2 ]; +* var zsh = [ 3, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 4, 2, 1 ]; +* var sy = [ 4, 2, 1 ]; +* var sz = [ 4, 2, 1 ]; +* +* // Define the index offsets: +* var ox = 0; +* var oy = 0; +* var oz = 0; +* +* // Create the input ndarray descriptors: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': xsh, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* var y = { +* 'dtype': 'float64', +* 'data': ybuf, +* 'shape': ysh, +* 'strides': sy, +* 'offset': oy, +* 'order': 'row-major' +* }; +* +* // Create an output ndarray descriptor: +* var z = { +* 'dtype': 'float64', +* 'data': zbuf, +* 'shape': zsh, +* 'strides': sz, +* 'offset': oz, +* 'order': 'row-major' +* }; +* +* // Initialize ndarray descriptors representing subarray views: +* var views = [ +* { +* 'dtype': x.dtype, +* 'data': x.data, +* 'shape': [ 2, 2 ], +* 'strides': [ 2, 1 ], +* 'offset': x.offset, +* 'order': x.order +* }, +* { +* 'dtype': y.dtype, +* 'data': y.data, +* 'shape': [ 2, 2 ], +* 'strides': [ 2, 1 ], +* 'offset': y.offset, +* 'order': y.order +* }, +* { +* 'dtype': z.dtype, +* 'data': z.data, +* 'shape': [ 2, 2 ], +* 'strides': [ 2, 1 ], +* 'offset': z.offset, +* 'order': z.order +* } +* ]; +* +* // Define an input strategy: +* function inputStrategy( x ) { +* return { +* 'dtype': x.dtype, +* 'data': x.data, +* 'shape': [ 4 ], +* 'strides': [ 1 ], +* 'offset': x.offset, +* 'order': x.order +* }; +* } +* +* // Define an output strategy: +* function outputStrategy( x ) { +* return x; +* } +* +* var strategy = { +* 'input': inputStrategy, +* 'output': outputStrategy +* }; +* +* // Apply strided function: +* kernel( gwxpy, [ x, y, z ], views, [ 3 ], [ 4 ], [ 4 ], [ 4 ], strategy, strategy, strategy, {} ); +* +* var arr = ndarray2array( z.data, z.shape, z.strides, z.offset, z.order ); +* // returns [ [ [ 3.0, 5.0 ], [ 7.0, 9.0 ] ], [ [ 11.0, 13.0 ], [ 15.0, 17.0 ] ], [ [ 19.0, 21.0 ], [ 23.0, 25.0 ] ] ] +*/ +function kernel( fcn, arrays, views, shape, stridesX, stridesY, stridesZ, strategyX, strategyY, strategyZ, opts ) { // eslint-disable-line max-len, max-params + var dv0; + var S0; + var iv; + var i0; + var v; + var i; + + // Note on variable naming convention: S#, dv#, 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... + S0 = shape[ 0 ]; + dv0 = [ + stridesX[0], + stridesY[0], + stridesZ[0] + ]; + for ( i = 3; i < arrays.length; i++ ) { + dv0.push( arrays[i].strides[0] ); + } + // Resolve a list of pointers to the first indexed elements in the respective ndarrays: + iv = offsets( arrays ); + + // Shallow copy the list of views to an internal array so that we can update with reshaped views without impacting the original list of views: + v = copyIndexed( views ); + + // Iterate over the loop dimensions... + for ( i0 = 0; i0 < S0; i0++ ) { + setViewOffsets( views, iv ); + v[ 0 ] = strategyX.input( views[ 0 ] ); + v[ 1 ] = strategyY.input( views[ 1 ] ); + v[ 2 ] = strategyZ.input( views[ 2 ] ); + fcn( v, opts ); + strategyZ.output( views[ 2 ] ); + incrementOffsets( iv, dv0 ); + } +} + + +// EXPORTS // + +module.exports = kernel; diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/2d.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/2d.js new file mode 100644 index 000000000000..7544bfc9a996 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/2d.js @@ -0,0 +1,237 @@ +/** +* @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 isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); +var copyIndexed = require( '@stdlib/array/base/copy-indexed' ); +var incrementOffsets = require( '@stdlib/ndarray/base/kernels/utils/increment-offsets' ); +var setViewOffsets = require( '@stdlib/ndarray/base/set-descriptor-offsets' ); +var offsets = require( '@stdlib/ndarray/base/offsets' ); + + +// MAIN // + +/** +* Applies a one-dimensional strided array function to a list of specified dimensions in two input ndarrays and assigns results to a provided output ndarray. +* +* @private +* @param {Function} fcn - wrapper for a one-dimensional strided array function +* @param {Array} arrays - ndarray descriptors +* @param {Array} views - initialized ndarray descriptors representing subarray views +* @param {Array} shape - loop dimensions +* @param {Array} stridesX - loop dimension strides for the first input ndarray +* @param {Array} stridesY - loop dimension strides for the second input ndarray +* @param {Array} stridesZ - loop dimension strides for the output ndarray +* @param {Object} strategyX - strategy for marshaling data to and from a first input ndarray view +* @param {Object} strategyY - strategy for marshaling data to and from a second input ndarray view +* @param {Object} strategyZ - strategy for marshaling data to and from an output ndarray view +* @param {Options} opts - function options +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +* var gwxpy = require( '@stdlib/blas/ext/base/ndarray/gwxpy' ); +* +* // 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( [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0 ] ); +* var zbuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* // Define the array shapes: +* var xsh = [ 1, 3, 2, 2 ]; +* var ysh = [ 1, 3, 2, 2 ]; +* var zsh = [ 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 ]; +* +* // Define the index offsets: +* var ox = 0; +* var oy = 0; +* var oz = 0; +* +* // Create the input ndarray descriptors: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': xsh, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* var y = { +* 'dtype': 'float64', +* 'data': ybuf, +* 'shape': ysh, +* 'strides': sy, +* 'offset': oy, +* 'order': 'row-major' +* }; +* +* // Create an output ndarray descriptor: +* var z = { +* 'dtype': 'float64', +* 'data': zbuf, +* 'shape': zsh, +* 'strides': sz, +* 'offset': oz, +* 'order': 'row-major' +* }; +* +* // Initialize ndarray descriptors representing subarray views: +* var views = [ +* { +* 'dtype': x.dtype, +* 'data': x.data, +* 'shape': [ 2, 2 ], +* 'strides': [ 2, 1 ], +* 'offset': x.offset, +* 'order': x.order +* }, +* { +* 'dtype': y.dtype, +* 'data': y.data, +* 'shape': [ 2, 2 ], +* 'strides': [ 2, 1 ], +* 'offset': y.offset, +* 'order': y.order +* }, +* { +* 'dtype': z.dtype, +* 'data': z.data, +* 'shape': [ 2, 2 ], +* 'strides': [ 2, 1 ], +* 'offset': z.offset, +* 'order': z.order +* } +* ]; +* +* // Define an input strategy: +* function inputStrategy( x ) { +* return { +* 'dtype': x.dtype, +* 'data': x.data, +* 'shape': [ 4 ], +* 'strides': [ 1 ], +* 'offset': x.offset, +* 'order': x.order +* }; +* } +* +* // Define an output strategy: +* function outputStrategy( x ) { +* return x; +* } +* +* var strategy = { +* 'input': inputStrategy, +* 'output': outputStrategy +* }; +* +* // Apply strided function: +* kernel( gwxpy, [ x, y, z ], views, [ 1, 3 ], [ 12, 4 ], [ 12, 4 ], [ 12, 4 ], strategy, strategy, strategy, {} ); +* +* var arr = ndarray2array( z.data, z.shape, z.strides, z.offset, z.order ); +* // returns [ [ [ [ 3.0, 5.0 ], [ 7.0, 9.0 ] ], [ [ 11.0, 13.0 ], [ 15.0, 17.0 ] ], [ [ 19.0, 21.0 ], [ 23.0, 25.0 ] ] ] ] +*/ +function kernel( fcn, arrays, views, shape, stridesX, stridesY, stridesZ, strategyX, strategyY, strategyZ, opts ) { // eslint-disable-line max-len, max-params + var dv0; + var dv1; + var S0; + var S1; + var sv; + var iv; + var i0; + var i1; + var v; + var i; + + // Note on variable naming convention: S#, dv#, 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... + if ( isRowMajor( stridesX ) ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = shape[ 1 ]; + S1 = shape[ 0 ]; + dv0 = [ // offset increment for innermost loop + stridesX[1], + stridesY[1], + stridesZ[1] + ]; + dv1 = [ // offset increment for outermost loop + stridesX[0] - ( S0*stridesX[1] ), + stridesY[0] - ( S0*stridesY[1] ), + stridesZ[0] - ( S0*stridesZ[1] ) + ]; + for ( i = 3; i < arrays.length; i++ ) { + sv = arrays[ i ].strides; + dv0.push( sv[1] ); + dv1.push( sv[0] - ( S0*sv[1] ) ); + } + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = shape[ 0 ]; + S1 = shape[ 1 ]; + dv0 = [ // offset increment for innermost loop + stridesX[0], + stridesY[0], + stridesZ[0] + ]; + dv1 = [ // offset increment for outermost loop + stridesX[1] - ( S0*stridesX[0] ), + stridesY[1] - ( S0*stridesY[0] ), + stridesZ[1] - ( S0*stridesZ[0] ) + ]; + for ( i = 3; i < arrays.length; i++ ) { + sv = arrays[ i ].strides; + dv0.push( sv[0] ); + dv1.push( sv[1] - ( S0*sv[0] ) ); + } + } + // Resolve a list of pointers to the first indexed elements in the respective ndarrays: + iv = offsets( arrays ); + + // Shallow copy the list of views to an internal array so that we can update with reshaped views without impacting the original list of views: + v = copyIndexed( views ); + + // Iterate over the loop dimensions... + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + setViewOffsets( views, iv ); + v[ 0 ] = strategyX.input( views[ 0 ] ); + v[ 1 ] = strategyY.input( views[ 1 ] ); + v[ 2 ] = strategyZ.input( views[ 2 ] ); + fcn( v, opts ); + strategyZ.output( views[ 2 ] ); + incrementOffsets( iv, dv0 ); + } + incrementOffsets( iv, dv1 ); + } +} + + +// EXPORTS // + +module.exports = kernel; diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/3d.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/3d.js new file mode 100644 index 000000000000..bb7eb0c243a7 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/3d.js @@ -0,0 +1,257 @@ +/** +* @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 isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); +var copyIndexed = require( '@stdlib/array/base/copy-indexed' ); +var incrementOffsets = require( '@stdlib/ndarray/base/kernels/utils/increment-offsets' ); +var setViewOffsets = require( '@stdlib/ndarray/base/set-descriptor-offsets' ); +var offsets = require( '@stdlib/ndarray/base/offsets' ); + + +// MAIN // + +/** +* Applies a one-dimensional strided array function to a list of specified dimensions in two input ndarrays and assigns results to a provided output ndarray. +* +* @private +* @param {Function} fcn - wrapper for a one-dimensional strided array function +* @param {Array} arrays - ndarray descriptors +* @param {Array} views - initialized ndarray descriptors representing subarray views +* @param {Array} shape - loop dimensions +* @param {Array} stridesX - loop dimension strides for the first input ndarray +* @param {Array} stridesY - loop dimension strides for the second input ndarray +* @param {Array} stridesZ - loop dimension strides for the output ndarray +* @param {Object} strategyX - strategy for marshaling data to and from a first input ndarray view +* @param {Object} strategyY - strategy for marshaling data to and from a second input ndarray view +* @param {Object} strategyZ - strategy for marshaling data to and from an output ndarray view +* @param {Options} opts - function options +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +* var gwxpy = require( '@stdlib/blas/ext/base/ndarray/gwxpy' ); +* +* // 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( [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0 ] ); +* var zbuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* // Define the array shapes: +* var xsh = [ 1, 1, 3, 2, 2 ]; +* var ysh = [ 1, 1, 3, 2, 2 ]; +* var zsh = [ 1, 1, 3, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 12, 12, 4, 2, 1 ]; +* var sy = [ 12, 12, 4, 2, 1 ]; +* var sz = [ 12, 12, 4, 2, 1 ]; +* +* // Define the index offsets: +* var ox = 0; +* var oy = 0; +* var oz = 0; +* +* // Create the input ndarray descriptors: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': xsh, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* var y = { +* 'dtype': 'float64', +* 'data': ybuf, +* 'shape': ysh, +* 'strides': sy, +* 'offset': oy, +* 'order': 'row-major' +* }; +* +* // Create an output ndarray descriptor: +* var z = { +* 'dtype': 'float64', +* 'data': zbuf, +* 'shape': zsh, +* 'strides': sz, +* 'offset': oz, +* 'order': 'row-major' +* }; +* +* // Initialize ndarray descriptors representing subarray views: +* var views = [ +* { +* 'dtype': x.dtype, +* 'data': x.data, +* 'shape': [ 2, 2 ], +* 'strides': [ 2, 1 ], +* 'offset': x.offset, +* 'order': x.order +* }, +* { +* 'dtype': y.dtype, +* 'data': y.data, +* 'shape': [ 2, 2 ], +* 'strides': [ 2, 1 ], +* 'offset': y.offset, +* 'order': y.order +* }, +* { +* 'dtype': z.dtype, +* 'data': z.data, +* 'shape': [ 2, 2 ], +* 'strides': [ 2, 1 ], +* 'offset': z.offset, +* 'order': z.order +* } +* ]; +* +* // Define an input strategy: +* function inputStrategy( x ) { +* return { +* 'dtype': x.dtype, +* 'data': x.data, +* 'shape': [ 4 ], +* 'strides': [ 1 ], +* 'offset': x.offset, +* 'order': x.order +* }; +* } +* +* // Define an output strategy: +* function outputStrategy( x ) { +* return x; +* } +* +* var strategy = { +* 'input': inputStrategy, +* 'output': outputStrategy +* }; +* +* // Apply strided function: +* kernel( gwxpy, [ x, y, z ], views, [ 1, 1, 3 ], [ 12, 12, 4 ], [ 12, 12, 4 ], [ 12, 12, 4 ], strategy, strategy, strategy, {} ); +* +* var arr = ndarray2array( z.data, z.shape, z.strides, z.offset, z.order ); +* // returns [ [ [ [ [ 3.0, 5.0 ], [ 7.0, 9.0 ] ], [ [ 11.0, 13.0 ], [ 15.0, 17.0 ] ], [ [ 19.0, 21.0 ], [ 23.0, 25.0 ] ] ] ] ] +*/ +function kernel( fcn, arrays, views, shape, stridesX, stridesY, stridesZ, strategyX, strategyY, strategyZ, opts ) { // eslint-disable-line max-len, max-params + var dv0; + var dv1; + var dv2; + var S0; + var S1; + var S2; + var sv; + var iv; + var i0; + var i1; + var i2; + var v; + var i; + + // Note on variable naming convention: S#, dv#, 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... + if ( isRowMajor( stridesX ) ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = shape[ 2 ]; + S1 = shape[ 1 ]; + S2 = shape[ 0 ]; + dv0 = [ // offset increment for innermost loop + stridesX[2], + stridesY[2], + stridesZ[2] + ]; + dv1 = [ + stridesX[1] - ( S0*stridesX[2] ), + stridesY[1] - ( S0*stridesY[2] ), + stridesZ[1] - ( S0*stridesZ[2] ) + ]; + dv2 = [ // offset increment for outermost loop + stridesX[0] - ( S1*stridesX[1] ), + stridesY[0] - ( S1*stridesY[1] ), + stridesZ[0] - ( S1*stridesZ[1] ) + ]; + for ( i = 3; i < arrays.length; i++ ) { + sv = arrays[ i ].strides; + dv0.push( sv[2] ); + dv1.push( sv[1] - ( S0*sv[2] ) ); + dv2.push( sv[0] - ( S1*sv[1] ) ); + } + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = shape[ 0 ]; + S1 = shape[ 1 ]; + S2 = shape[ 2 ]; + dv0 = [ // offset increment for innermost loop + stridesX[0], + stridesY[0], + stridesZ[0] + ]; + dv1 = [ + stridesX[1] - ( S0*stridesX[0] ), + stridesY[1] - ( S0*stridesY[0] ), + stridesZ[1] - ( S0*stridesZ[0] ) + ]; + dv2 = [ // offset increment for outermost loop + stridesX[2] - ( S1*stridesX[1] ), + stridesY[2] - ( S1*stridesY[1] ), + stridesZ[2] - ( S1*stridesZ[1] ) + ]; + for ( i = 3; i < arrays.length; i++ ) { + sv = arrays[ i ].strides; + dv0.push( sv[0] ); + dv1.push( sv[1] - ( S0*sv[0] ) ); + dv2.push( sv[2] - ( S1*sv[1] ) ); + } + } + // Resolve a list of pointers to the first indexed elements in the respective ndarrays: + iv = offsets( arrays ); + + // Shallow copy the list of views to an internal array so that we can update with reshaped views without impacting the original list of views: + v = copyIndexed( views ); + + // Iterate over the loop dimensions... + for ( i2 = 0; i2 < S2; i2++ ) { + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + setViewOffsets( views, iv ); + v[ 0 ] = strategyX.input( views[ 0 ] ); + v[ 1 ] = strategyY.input( views[ 1 ] ); + v[ 2 ] = strategyZ.input( views[ 2 ] ); + fcn( v, opts ); + strategyZ.output( views[ 2 ] ); + incrementOffsets( iv, dv0 ); + } + incrementOffsets( iv, dv1 ); + } + incrementOffsets( iv, dv2 ); + } +} + + +// EXPORTS // + +module.exports = kernel; diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/4d.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/4d.js new file mode 100644 index 000000000000..269d0c254bd0 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/4d.js @@ -0,0 +1,277 @@ +/** +* @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 isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); +var copyIndexed = require( '@stdlib/array/base/copy-indexed' ); +var incrementOffsets = require( '@stdlib/ndarray/base/kernels/utils/increment-offsets' ); +var setViewOffsets = require( '@stdlib/ndarray/base/set-descriptor-offsets' ); +var offsets = require( '@stdlib/ndarray/base/offsets' ); + + +// MAIN // + +/** +* Applies a one-dimensional strided array function to a list of specified dimensions in two input ndarrays and assigns results to a provided output ndarray. +* +* @private +* @param {Function} fcn - wrapper for a one-dimensional strided array function +* @param {Array} arrays - ndarray descriptors +* @param {Array} views - initialized ndarray descriptors representing subarray views +* @param {Array} shape - loop dimensions +* @param {Array} stridesX - loop dimension strides for the first input ndarray +* @param {Array} stridesY - loop dimension strides for the second input ndarray +* @param {Array} stridesZ - loop dimension strides for the output ndarray +* @param {Object} strategyX - strategy for marshaling data to and from a first input ndarray view +* @param {Object} strategyY - strategy for marshaling data to and from a second input ndarray view +* @param {Object} strategyZ - strategy for marshaling data to and from an output ndarray view +* @param {Options} opts - function options +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +* var gwxpy = require( '@stdlib/blas/ext/base/ndarray/gwxpy' ); +* +* // 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( [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0 ] ); +* var zbuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* // Define the array shapes: +* var xsh = [ 1, 1, 1, 3, 2, 2 ]; +* var ysh = [ 1, 1, 1, 3, 2, 2 ]; +* var zsh = [ 1, 1, 1, 3, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 12, 12, 12, 4, 2, 1 ]; +* var sy = [ 12, 12, 12, 4, 2, 1 ]; +* var sz = [ 12, 12, 12, 4, 2, 1 ]; +* +* // Define the index offsets: +* var ox = 0; +* var oy = 0; +* var oz = 0; +* +* // Create the input ndarray descriptors: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': xsh, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* var y = { +* 'dtype': 'float64', +* 'data': ybuf, +* 'shape': ysh, +* 'strides': sy, +* 'offset': oy, +* 'order': 'row-major' +* }; +* +* // Create an output ndarray descriptor: +* var z = { +* 'dtype': 'float64', +* 'data': zbuf, +* 'shape': zsh, +* 'strides': sz, +* 'offset': oz, +* 'order': 'row-major' +* }; +* +* // Initialize ndarray descriptors representing subarray views: +* var views = [ +* { +* 'dtype': x.dtype, +* 'data': x.data, +* 'shape': [ 2, 2 ], +* 'strides': [ 2, 1 ], +* 'offset': x.offset, +* 'order': x.order +* }, +* { +* 'dtype': y.dtype, +* 'data': y.data, +* 'shape': [ 2, 2 ], +* 'strides': [ 2, 1 ], +* 'offset': y.offset, +* 'order': y.order +* }, +* { +* 'dtype': z.dtype, +* 'data': z.data, +* 'shape': [ 2, 2 ], +* 'strides': [ 2, 1 ], +* 'offset': z.offset, +* 'order': z.order +* } +* ]; +* +* // Define an input strategy: +* function inputStrategy( x ) { +* return { +* 'dtype': x.dtype, +* 'data': x.data, +* 'shape': [ 4 ], +* 'strides': [ 1 ], +* 'offset': x.offset, +* 'order': x.order +* }; +* } +* +* // Define an output strategy: +* function outputStrategy( x ) { +* return x; +* } +* +* var strategy = { +* 'input': inputStrategy, +* 'output': outputStrategy +* }; +* +* // Apply strided function: +* kernel( gwxpy, [ x, y, z ], views, [ 1, 1, 1, 3 ], [ 12, 12, 12, 4 ], [ 12, 12, 12, 4 ], [ 12, 12, 12, 4 ], strategy, strategy, strategy, {} ); +* +* var arr = ndarray2array( z.data, z.shape, z.strides, z.offset, z.order ); +* // returns [ [ [ [ [ [ 3.0, 5.0 ], [ 7.0, 9.0 ] ], [ [ 11.0, 13.0 ], [ 15.0, 17.0 ] ], [ [ 19.0, 21.0 ], [ 23.0, 25.0 ] ] ] ] ] ] +*/ +function kernel( fcn, arrays, views, shape, stridesX, stridesY, stridesZ, strategyX, strategyY, strategyZ, opts ) { // eslint-disable-line max-len, max-params + var dv0; + var dv1; + var dv2; + var dv3; + var S0; + var S1; + var S2; + var S3; + var sv; + var iv; + var i0; + var i1; + var i2; + var i3; + var v; + var i; + + // Note on variable naming convention: S#, dv#, 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... + if ( isRowMajor( stridesX ) ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = shape[ 3 ]; + S1 = shape[ 2 ]; + S2 = shape[ 1 ]; + S3 = shape[ 0 ]; + dv0 = [ // offset increment for innermost loop + stridesX[3], + stridesY[3], + stridesZ[3] + ]; + dv1 = [ + stridesX[2] - ( S0*stridesX[3] ), + stridesY[2] - ( S0*stridesY[3] ), + stridesZ[2] - ( S0*stridesZ[3] ) + ]; + dv2 = [ + stridesX[1] - ( S1*stridesX[2] ), + stridesY[1] - ( S1*stridesY[2] ), + stridesZ[1] - ( S1*stridesZ[2] ) + ]; + dv3 = [ // offset increment for outermost loop + stridesX[0] - ( S2*stridesX[1] ), + stridesY[0] - ( S2*stridesY[1] ), + stridesZ[0] - ( S2*stridesZ[1] ) + ]; + for ( i = 3; i < arrays.length; i++ ) { + sv = arrays[ i ].strides; + dv0.push( sv[3] ); + dv1.push( sv[2] - ( S0*sv[3] ) ); + dv2.push( sv[1] - ( S1*sv[2] ) ); + dv3.push( sv[0] - ( S2*sv[1] ) ); + } + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = shape[ 0 ]; + S1 = shape[ 1 ]; + S2 = shape[ 2 ]; + S3 = shape[ 3 ]; + dv0 = [ // offset increment for innermost loop + stridesX[0], + stridesY[0], + stridesZ[0] + ]; + dv1 = [ + stridesX[1] - ( S0*stridesX[0] ), + stridesY[1] - ( S0*stridesY[0] ), + stridesZ[1] - ( S0*stridesZ[0] ) + ]; + dv2 = [ + stridesX[2] - ( S1*stridesX[1] ), + stridesY[2] - ( S1*stridesY[1] ), + stridesZ[2] - ( S1*stridesZ[1] ) + ]; + dv3 = [ // offset increment for outermost loop + stridesX[3] - ( S2*stridesX[2] ), + stridesY[3] - ( S2*stridesY[2] ), + stridesZ[3] - ( S2*stridesZ[2] ) + ]; + for ( i = 3; i < arrays.length; i++ ) { + sv = arrays[ i ].strides; + dv0.push( sv[0] ); + dv1.push( sv[1] - ( S0*sv[0] ) ); + dv2.push( sv[2] - ( S1*sv[1] ) ); + dv3.push( sv[3] - ( S2*sv[2] ) ); + } + } + // Resolve a list of pointers to the first indexed elements in the respective ndarrays: + iv = offsets( arrays ); + + // Shallow copy the list of views to an internal array so that we can update with reshaped views without impacting the original list of views: + v = copyIndexed( views ); + + // Iterate over the loop 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++ ) { + setViewOffsets( views, iv ); + v[ 0 ] = strategyX.input( views[ 0 ] ); + v[ 1 ] = strategyY.input( views[ 1 ] ); + v[ 2 ] = strategyZ.input( views[ 2 ] ); + fcn( v, opts ); + strategyZ.output( views[ 2 ] ); + incrementOffsets( iv, dv0 ); + } + incrementOffsets( iv, dv1 ); + } + incrementOffsets( iv, dv2 ); + } + incrementOffsets( iv, dv3 ); + } +} + + +// EXPORTS // + +module.exports = kernel; diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/5d.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/5d.js new file mode 100644 index 000000000000..423f0f3d8048 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/5d.js @@ -0,0 +1,297 @@ +/** +* @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 isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); +var copyIndexed = require( '@stdlib/array/base/copy-indexed' ); +var incrementOffsets = require( '@stdlib/ndarray/base/kernels/utils/increment-offsets' ); +var setViewOffsets = require( '@stdlib/ndarray/base/set-descriptor-offsets' ); +var offsets = require( '@stdlib/ndarray/base/offsets' ); + + +// MAIN // + +/** +* Applies a one-dimensional strided array function to a list of specified dimensions in two input ndarrays and assigns results to a provided output ndarray. +* +* @private +* @param {Function} fcn - wrapper for a one-dimensional strided array function +* @param {Array} arrays - ndarray descriptors +* @param {Array} views - initialized ndarray descriptors representing subarray views +* @param {Array} shape - loop dimensions +* @param {Array} stridesX - loop dimension strides for the first input ndarray +* @param {Array} stridesY - loop dimension strides for the second input ndarray +* @param {Array} stridesZ - loop dimension strides for the output ndarray +* @param {Object} strategyX - strategy for marshaling data to and from a first input ndarray view +* @param {Object} strategyY - strategy for marshaling data to and from a second input ndarray view +* @param {Object} strategyZ - strategy for marshaling data to and from an output ndarray view +* @param {Options} opts - function options +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +* var gwxpy = require( '@stdlib/blas/ext/base/ndarray/gwxpy' ); +* +* // 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( [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0 ] ); +* var zbuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* // Define the array shapes: +* var xsh = [ 1, 1, 1, 1, 3, 2, 2 ]; +* var ysh = [ 1, 1, 1, 1, 3, 2, 2 ]; +* var zsh = [ 1, 1, 1, 1, 3, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 12, 12, 12, 12, 4, 2, 1 ]; +* var sy = [ 12, 12, 12, 12, 4, 2, 1 ]; +* var sz = [ 12, 12, 12, 12, 4, 2, 1 ]; +* +* // Define the index offsets: +* var ox = 0; +* var oy = 0; +* var oz = 0; +* +* // Create the input ndarray descriptors: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': xsh, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* var y = { +* 'dtype': 'float64', +* 'data': ybuf, +* 'shape': ysh, +* 'strides': sy, +* 'offset': oy, +* 'order': 'row-major' +* }; +* +* // Create an output ndarray descriptor: +* var z = { +* 'dtype': 'float64', +* 'data': zbuf, +* 'shape': zsh, +* 'strides': sz, +* 'offset': oz, +* 'order': 'row-major' +* }; +* +* // Initialize ndarray descriptors representing subarray views: +* var views = [ +* { +* 'dtype': x.dtype, +* 'data': x.data, +* 'shape': [ 2, 2 ], +* 'strides': [ 2, 1 ], +* 'offset': x.offset, +* 'order': x.order +* }, +* { +* 'dtype': y.dtype, +* 'data': y.data, +* 'shape': [ 2, 2 ], +* 'strides': [ 2, 1 ], +* 'offset': y.offset, +* 'order': y.order +* }, +* { +* 'dtype': z.dtype, +* 'data': z.data, +* 'shape': [ 2, 2 ], +* 'strides': [ 2, 1 ], +* 'offset': z.offset, +* 'order': z.order +* } +* ]; +* +* // Define an input strategy: +* function inputStrategy( x ) { +* return { +* 'dtype': x.dtype, +* 'data': x.data, +* 'shape': [ 4 ], +* 'strides': [ 1 ], +* 'offset': x.offset, +* 'order': x.order +* }; +* } +* +* // Define an output strategy: +* function outputStrategy( x ) { +* return x; +* } +* +* var strategy = { +* 'input': inputStrategy, +* 'output': outputStrategy +* }; +* +* // Apply strided function: +* kernel( gwxpy, [ x, y, z ], views, [ 1, 1, 1, 1, 3 ], [ 12, 12, 12, 12, 4 ], [ 12, 12, 12, 12, 4 ], [ 12, 12, 12, 12, 4 ], strategy, strategy, strategy, {} ); +* +* var arr = ndarray2array( z.data, z.shape, z.strides, z.offset, z.order ); +* // returns [ [ [ [ [ [ [ 3.0, 5.0 ], [ 7.0, 9.0 ] ], [ [ 11.0, 13.0 ], [ 15.0, 17.0 ] ], [ [ 19.0, 21.0 ], [ 23.0, 25.0 ] ] ] ] ] ] ] +*/ +function kernel( fcn, arrays, views, shape, stridesX, stridesY, stridesZ, strategyX, strategyY, strategyZ, opts ) { // eslint-disable-line max-len, max-params + var dv0; + var dv1; + var dv2; + var dv3; + var dv4; + var S0; + var S1; + var S2; + var S3; + var S4; + var sv; + var iv; + var i0; + var i1; + var i2; + var i3; + var i4; + var v; + var i; + + // Note on variable naming convention: S#, dv#, 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... + if ( isRowMajor( stridesX ) ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = shape[ 4 ]; + S1 = shape[ 3 ]; + S2 = shape[ 2 ]; + S3 = shape[ 1 ]; + S4 = shape[ 0 ]; + dv0 = [ // offset increment for innermost loop + stridesX[4], + stridesY[4], + stridesZ[4] + ]; + dv1 = [ + stridesX[3] - ( S0*stridesX[4] ), + stridesY[3] - ( S0*stridesY[4] ), + stridesZ[3] - ( S0*stridesZ[4] ) + ]; + dv2 = [ + stridesX[2] - ( S1*stridesX[3] ), + stridesY[2] - ( S1*stridesY[3] ), + stridesZ[2] - ( S1*stridesZ[3] ) + ]; + dv3 = [ + stridesX[1] - ( S2*stridesX[2] ), + stridesY[1] - ( S2*stridesY[2] ), + stridesZ[1] - ( S2*stridesZ[2] ) + ]; + dv4 = [ // offset increment for outermost loop + stridesX[0] - ( S3*stridesX[1] ), + stridesY[0] - ( S3*stridesY[1] ), + stridesZ[0] - ( S3*stridesZ[1] ) + ]; + for ( i = 3; i < arrays.length; i++ ) { + sv = arrays[ i ].strides; + dv0.push( sv[4] ); + dv1.push( sv[3] - ( S0*sv[4] ) ); + dv2.push( sv[2] - ( S1*sv[3] ) ); + dv3.push( sv[1] - ( S2*sv[2] ) ); + dv4.push( sv[0] - ( S3*sv[1] ) ); + } + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = shape[ 0 ]; + S1 = shape[ 1 ]; + S2 = shape[ 2 ]; + S3 = shape[ 3 ]; + S4 = shape[ 4 ]; + dv0 = [ // offset increment for innermost loop + stridesX[0], + stridesY[0], + stridesZ[0] + ]; + dv1 = [ + stridesX[1] - ( S0*stridesX[0] ), + stridesY[1] - ( S0*stridesY[0] ), + stridesZ[1] - ( S0*stridesZ[0] ) + ]; + dv2 = [ + stridesX[2] - ( S1*stridesX[1] ), + stridesY[2] - ( S1*stridesY[1] ), + stridesZ[2] - ( S1*stridesZ[1] ) + ]; + dv3 = [ + stridesX[3] - ( S2*stridesX[2] ), + stridesY[3] - ( S2*stridesY[2] ), + stridesZ[3] - ( S2*stridesZ[2] ) + ]; + dv4 = [ // offset increment for outermost loop + stridesX[4] - ( S3*stridesX[3] ), + stridesY[4] - ( S3*stridesY[3] ), + stridesZ[4] - ( S3*stridesZ[3] ) + ]; + for ( i = 3; i < arrays.length; i++ ) { + sv = arrays[ i ].strides; + dv0.push( sv[0] ); + dv1.push( sv[1] - ( S0*sv[0] ) ); + dv2.push( sv[2] - ( S1*sv[1] ) ); + dv3.push( sv[3] - ( S2*sv[2] ) ); + dv4.push( sv[4] - ( S3*sv[3] ) ); + } + } + // Resolve a list of pointers to the first indexed elements in the respective ndarrays: + iv = offsets( arrays ); + + // Shallow copy the list of views to an internal array so that we can update with reshaped views without impacting the original list of views: + v = copyIndexed( views ); + + // Iterate over the loop 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++ ) { + setViewOffsets( views, iv ); + v[ 0 ] = strategyX.input( views[ 0 ] ); + v[ 1 ] = strategyY.input( views[ 1 ] ); + v[ 2 ] = strategyZ.input( views[ 2 ] ); + fcn( v, opts ); + strategyZ.output( views[ 2 ] ); + incrementOffsets( iv, dv0 ); + } + incrementOffsets( iv, dv1 ); + } + incrementOffsets( iv, dv2 ); + } + incrementOffsets( iv, dv3 ); + } + incrementOffsets( iv, dv4 ); + } +} + + +// EXPORTS // + +module.exports = kernel; diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/6d.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/6d.js new file mode 100644 index 000000000000..2e52f94de4c9 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/6d.js @@ -0,0 +1,319 @@ +/** +* @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-depth */ + +'use strict'; + +// MODULES // + +var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); +var copyIndexed = require( '@stdlib/array/base/copy-indexed' ); +var incrementOffsets = require( '@stdlib/ndarray/base/kernels/utils/increment-offsets' ); +var setViewOffsets = require( '@stdlib/ndarray/base/set-descriptor-offsets' ); +var offsets = require( '@stdlib/ndarray/base/offsets' ); + + +// MAIN // + +/** +* Applies a one-dimensional strided array function to a list of specified dimensions in two input ndarrays and assigns results to a provided output ndarray. +* +* @private +* @param {Function} fcn - wrapper for a one-dimensional strided array function +* @param {Array} arrays - ndarray descriptors +* @param {Array} views - initialized ndarray descriptors representing subarray views +* @param {Array} shape - loop dimensions +* @param {Array} stridesX - loop dimension strides for the first input ndarray +* @param {Array} stridesY - loop dimension strides for the second input ndarray +* @param {Array} stridesZ - loop dimension strides for the output ndarray +* @param {Object} strategyX - strategy for marshaling data to and from a first input ndarray view +* @param {Object} strategyY - strategy for marshaling data to and from a second input ndarray view +* @param {Object} strategyZ - strategy for marshaling data to and from an output ndarray view +* @param {Options} opts - function options +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +* var gwxpy = require( '@stdlib/blas/ext/base/ndarray/gwxpy' ); +* +* // 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( [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0 ] ); +* var zbuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* // Define the array shapes: +* var xsh = [ 1, 1, 1, 1, 1, 3, 2, 2 ]; +* var ysh = [ 1, 1, 1, 1, 1, 3, 2, 2 ]; +* var zsh = [ 1, 1, 1, 1, 1, 3, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 12, 12, 12, 12, 12, 4, 2, 1 ]; +* var sy = [ 12, 12, 12, 12, 12, 4, 2, 1 ]; +* var sz = [ 12, 12, 12, 12, 12, 4, 2, 1 ]; +* +* // Define the index offsets: +* var ox = 0; +* var oy = 0; +* var oz = 0; +* +* // Create the input ndarray descriptors: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': xsh, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* var y = { +* 'dtype': 'float64', +* 'data': ybuf, +* 'shape': ysh, +* 'strides': sy, +* 'offset': oy, +* 'order': 'row-major' +* }; +* +* // Create an output ndarray descriptor: +* var z = { +* 'dtype': 'float64', +* 'data': zbuf, +* 'shape': zsh, +* 'strides': sz, +* 'offset': oz, +* 'order': 'row-major' +* }; +* +* // Initialize ndarray descriptors representing subarray views: +* var views = [ +* { +* 'dtype': x.dtype, +* 'data': x.data, +* 'shape': [ 2, 2 ], +* 'strides': [ 2, 1 ], +* 'offset': x.offset, +* 'order': x.order +* }, +* { +* 'dtype': y.dtype, +* 'data': y.data, +* 'shape': [ 2, 2 ], +* 'strides': [ 2, 1 ], +* 'offset': y.offset, +* 'order': y.order +* }, +* { +* 'dtype': z.dtype, +* 'data': z.data, +* 'shape': [ 2, 2 ], +* 'strides': [ 2, 1 ], +* 'offset': z.offset, +* 'order': z.order +* } +* ]; +* +* // Define an input strategy: +* function inputStrategy( x ) { +* return { +* 'dtype': x.dtype, +* 'data': x.data, +* 'shape': [ 4 ], +* 'strides': [ 1 ], +* 'offset': x.offset, +* 'order': x.order +* }; +* } +* +* // Define an output strategy: +* function outputStrategy( x ) { +* return x; +* } +* +* var strategy = { +* 'input': inputStrategy, +* 'output': outputStrategy +* }; +* +* // Apply strided function: +* kernel( gwxpy, [ x, y, z ], views, [ 1, 1, 1, 1, 1, 3 ], [ 12, 12, 12, 12, 12, 4 ], [ 12, 12, 12, 12, 12, 4 ], [ 12, 12, 12, 12, 12, 4 ], strategy, strategy, strategy, {} ); +* +* var arr = ndarray2array( z.data, z.shape, z.strides, z.offset, z.order ); +* // returns [ [ [ [ [ [ [ [ 3.0, 5.0 ], [ 7.0, 9.0 ] ], [ [ 11.0, 13.0 ], [ 15.0, 17.0 ] ], [ [ 19.0, 21.0 ], [ 23.0, 25.0 ] ] ] ] ] ] ] ] +*/ +function kernel( fcn, arrays, views, shape, stridesX, stridesY, stridesZ, strategyX, strategyY, strategyZ, opts ) { // eslint-disable-line max-len, max-params + var dv0; + var dv1; + var dv2; + var dv3; + var dv4; + var dv5; + var S0; + var S1; + var S2; + var S3; + var S4; + var S5; + var sv; + var iv; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var v; + var i; + + // Note on variable naming convention: S#, dv#, 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... + if ( isRowMajor( stridesX ) ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = shape[ 5 ]; + S1 = shape[ 4 ]; + S2 = shape[ 3 ]; + S3 = shape[ 2 ]; + S4 = shape[ 1 ]; + S5 = shape[ 0 ]; + dv0 = [ // offset increment for innermost loop + stridesX[5], + stridesY[5], + stridesZ[5] + ]; + dv1 = [ + stridesX[4] - ( S0*stridesX[5] ), + stridesY[4] - ( S0*stridesY[5] ), + stridesZ[4] - ( S0*stridesZ[5] ) + ]; + dv2 = [ + stridesX[3] - ( S1*stridesX[4] ), + stridesY[3] - ( S1*stridesY[4] ), + stridesZ[3] - ( S1*stridesZ[4] ) + ]; + dv3 = [ + stridesX[2] - ( S2*stridesX[3] ), + stridesY[2] - ( S2*stridesY[3] ), + stridesZ[2] - ( S2*stridesZ[3] ) + ]; + dv4 = [ + stridesX[1] - ( S3*stridesX[2] ), + stridesY[1] - ( S3*stridesY[2] ), + stridesZ[1] - ( S3*stridesZ[2] ) + ]; + dv5 = [ // offset increment for outermost loop + stridesX[0] - ( S4*stridesX[1] ), + stridesY[0] - ( S4*stridesY[1] ), + stridesZ[0] - ( S4*stridesZ[1] ) + ]; + for ( i = 3; i < arrays.length; i++ ) { + sv = arrays[ i ].strides; + dv0.push( sv[5] ); + dv1.push( sv[4] - ( S0*sv[5] ) ); + dv2.push( sv[3] - ( S1*sv[4] ) ); + dv3.push( sv[2] - ( S2*sv[3] ) ); + dv4.push( sv[1] - ( S3*sv[2] ) ); + dv5.push( sv[0] - ( S4*sv[1] ) ); + } + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = shape[ 0 ]; + S1 = shape[ 1 ]; + S2 = shape[ 2 ]; + S3 = shape[ 3 ]; + S4 = shape[ 4 ]; + S5 = shape[ 5 ]; + dv0 = [ // offset increment for innermost loop + stridesX[0], + stridesY[0], + stridesZ[0] + ]; + dv1 = [ + stridesX[1] - ( S0*stridesX[0] ), + stridesY[1] - ( S0*stridesY[0] ), + stridesZ[1] - ( S0*stridesZ[0] ) + ]; + dv2 = [ + stridesX[2] - ( S1*stridesX[1] ), + stridesY[2] - ( S1*stridesY[1] ), + stridesZ[2] - ( S1*stridesZ[1] ) + ]; + dv3 = [ + stridesX[3] - ( S2*stridesX[2] ), + stridesY[3] - ( S2*stridesY[2] ), + stridesZ[3] - ( S2*stridesZ[2] ) + ]; + dv4 = [ + stridesX[4] - ( S3*stridesX[3] ), + stridesY[4] - ( S3*stridesY[3] ), + stridesZ[4] - ( S3*stridesZ[3] ) + ]; + dv5 = [ // offset increment for outermost loop + stridesX[5] - ( S4*stridesX[4] ), + stridesY[5] - ( S4*stridesY[4] ), + stridesZ[5] - ( S4*stridesZ[4] ) + ]; + for ( i = 3; i < arrays.length; i++ ) { + sv = arrays[ i ].strides; + dv0.push( sv[0] ); + dv1.push( sv[1] - ( S0*sv[0] ) ); + dv2.push( sv[2] - ( S1*sv[1] ) ); + dv3.push( sv[3] - ( S2*sv[2] ) ); + dv4.push( sv[4] - ( S3*sv[3] ) ); + dv5.push( sv[5] - ( S4*sv[4] ) ); + } + } + // Resolve a list of pointers to the first indexed elements in the respective ndarrays: + iv = offsets( arrays ); + + // Shallow copy the list of views to an internal array so that we can update with reshaped views without impacting the original list of views: + v = copyIndexed( views ); + + // Iterate over the loop 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++ ) { + setViewOffsets( views, iv ); + v[ 0 ] = strategyX.input( views[ 0 ] ); + v[ 1 ] = strategyY.input( views[ 1 ] ); + v[ 2 ] = strategyZ.input( views[ 2 ] ); + fcn( v, opts ); + strategyZ.output( views[ 2 ] ); + incrementOffsets( iv, dv0 ); + } + incrementOffsets( iv, dv1 ); + } + incrementOffsets( iv, dv2 ); + } + incrementOffsets( iv, dv3 ); + } + incrementOffsets( iv, dv4 ); + } + incrementOffsets( iv, dv5 ); + } +} + + +// EXPORTS // + +module.exports = kernel; diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/7d.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/7d.js new file mode 100644 index 000000000000..a0de93050407 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/7d.js @@ -0,0 +1,339 @@ +/** +* @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-depth */ + +'use strict'; + +// MODULES // + +var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); +var copyIndexed = require( '@stdlib/array/base/copy-indexed' ); +var incrementOffsets = require( '@stdlib/ndarray/base/kernels/utils/increment-offsets' ); +var setViewOffsets = require( '@stdlib/ndarray/base/set-descriptor-offsets' ); +var offsets = require( '@stdlib/ndarray/base/offsets' ); + + +// MAIN // + +/** +* Applies a one-dimensional strided array function to a list of specified dimensions in two input ndarrays and assigns results to a provided output ndarray. +* +* @private +* @param {Function} fcn - wrapper for a one-dimensional strided array function +* @param {Array} arrays - ndarray descriptors +* @param {Array} views - initialized ndarray descriptors representing subarray views +* @param {Array} shape - loop dimensions +* @param {Array} stridesX - loop dimension strides for the first input ndarray +* @param {Array} stridesY - loop dimension strides for the second input ndarray +* @param {Array} stridesZ - loop dimension strides for the output ndarray +* @param {Object} strategyX - strategy for marshaling data to and from a first input ndarray view +* @param {Object} strategyY - strategy for marshaling data to and from a second input ndarray view +* @param {Object} strategyZ - strategy for marshaling data to and from an output ndarray view +* @param {Options} opts - function options +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +* var gwxpy = require( '@stdlib/blas/ext/base/ndarray/gwxpy' ); +* +* // 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( [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0 ] ); +* var zbuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* // Define the array shapes: +* var xsh = [ 1, 1, 1, 1, 1, 1, 3, 2, 2 ]; +* var ysh = [ 1, 1, 1, 1, 1, 1, 3, 2, 2 ]; +* var zsh = [ 1, 1, 1, 1, 1, 1, 3, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 12, 12, 12, 12, 12, 12, 4, 2, 1 ]; +* var sy = [ 12, 12, 12, 12, 12, 12, 4, 2, 1 ]; +* var sz = [ 12, 12, 12, 12, 12, 12, 4, 2, 1 ]; +* +* // Define the index offsets: +* var ox = 0; +* var oy = 0; +* var oz = 0; +* +* // Create the input ndarray descriptors: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': xsh, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* var y = { +* 'dtype': 'float64', +* 'data': ybuf, +* 'shape': ysh, +* 'strides': sy, +* 'offset': oy, +* 'order': 'row-major' +* }; +* +* // Create an output ndarray descriptor: +* var z = { +* 'dtype': 'float64', +* 'data': zbuf, +* 'shape': zsh, +* 'strides': sz, +* 'offset': oz, +* 'order': 'row-major' +* }; +* +* // Initialize ndarray descriptors representing subarray views: +* var views = [ +* { +* 'dtype': x.dtype, +* 'data': x.data, +* 'shape': [ 2, 2 ], +* 'strides': [ 2, 1 ], +* 'offset': x.offset, +* 'order': x.order +* }, +* { +* 'dtype': y.dtype, +* 'data': y.data, +* 'shape': [ 2, 2 ], +* 'strides': [ 2, 1 ], +* 'offset': y.offset, +* 'order': y.order +* }, +* { +* 'dtype': z.dtype, +* 'data': z.data, +* 'shape': [ 2, 2 ], +* 'strides': [ 2, 1 ], +* 'offset': z.offset, +* 'order': z.order +* } +* ]; +* +* // Define an input strategy: +* function inputStrategy( x ) { +* return { +* 'dtype': x.dtype, +* 'data': x.data, +* 'shape': [ 4 ], +* 'strides': [ 1 ], +* 'offset': x.offset, +* 'order': x.order +* }; +* } +* +* // Define an output strategy: +* function outputStrategy( x ) { +* return x; +* } +* +* var strategy = { +* 'input': inputStrategy, +* 'output': outputStrategy +* }; +* +* // Apply strided function: +* kernel( gwxpy, [ x, y, z ], views, [ 1, 1, 1, 1, 1, 1, 3 ], [ 12, 12, 12, 12, 12, 12, 4 ], [ 12, 12, 12, 12, 12, 12, 4 ], [ 12, 12, 12, 12, 12, 12, 4 ], strategy, strategy, strategy, {} ); +* +* var arr = ndarray2array( z.data, z.shape, z.strides, z.offset, z.order ); +* // returns [ [ [ [ [ [ [ [ [ 3.0, 5.0 ], [ 7.0, 9.0 ] ], [ [ 11.0, 13.0 ], [ 15.0, 17.0 ] ], [ [ 19.0, 21.0 ], [ 23.0, 25.0 ] ] ] ] ] ] ] ] ] +*/ +function kernel( fcn, arrays, views, shape, stridesX, stridesY, stridesZ, strategyX, strategyY, strategyZ, opts ) { // eslint-disable-line max-len, max-params + var dv0; + var dv1; + var dv2; + var dv3; + var dv4; + var dv5; + var dv6; + var S0; + var S1; + var S2; + var S3; + var S4; + var S5; + var S6; + var sv; + var iv; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + var v; + var i; + + // Note on variable naming convention: S#, dv#, 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... + if ( isRowMajor( stridesX ) ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = shape[ 6 ]; + S1 = shape[ 5 ]; + S2 = shape[ 4 ]; + S3 = shape[ 3 ]; + S4 = shape[ 2 ]; + S5 = shape[ 1 ]; + S6 = shape[ 0 ]; + dv0 = [ // offset increment for innermost loop + stridesX[6], + stridesY[6], + stridesZ[6] + ]; + dv1 = [ + stridesX[5] - ( S0*stridesX[6] ), + stridesY[5] - ( S0*stridesY[6] ), + stridesZ[5] - ( S0*stridesZ[6] ) + ]; + dv2 = [ + stridesX[4] - ( S1*stridesX[5] ), + stridesY[4] - ( S1*stridesY[5] ), + stridesZ[4] - ( S1*stridesZ[5] ) + ]; + dv3 = [ + stridesX[3] - ( S2*stridesX[4] ), + stridesY[3] - ( S2*stridesY[4] ), + stridesZ[3] - ( S2*stridesZ[4] ) + ]; + dv4 = [ + stridesX[2] - ( S3*stridesX[3] ), + stridesY[2] - ( S3*stridesY[3] ), + stridesZ[2] - ( S3*stridesZ[3] ) + ]; + dv5 = [ + stridesX[1] - ( S4*stridesX[2] ), + stridesY[1] - ( S4*stridesY[2] ), + stridesZ[1] - ( S4*stridesZ[2] ) + ]; + dv6 = [ // offset increment for outermost loop + stridesX[0] - ( S5*stridesX[1] ), + stridesY[0] - ( S5*stridesY[1] ), + stridesZ[0] - ( S5*stridesZ[1] ) + ]; + for ( i = 3; i < arrays.length; i++ ) { + sv = arrays[ i ].strides; + dv0.push( sv[6] ); + dv1.push( sv[5] - ( S0*sv[6] ) ); + dv2.push( sv[4] - ( S1*sv[5] ) ); + dv3.push( sv[3] - ( S2*sv[4] ) ); + dv4.push( sv[2] - ( S3*sv[3] ) ); + dv5.push( sv[1] - ( S4*sv[2] ) ); + dv6.push( sv[0] - ( S5*sv[1] ) ); + } + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = shape[ 0 ]; + S1 = shape[ 1 ]; + S2 = shape[ 2 ]; + S3 = shape[ 3 ]; + S4 = shape[ 4 ]; + S5 = shape[ 5 ]; + S6 = shape[ 6 ]; + dv0 = [ // offset increment for innermost loop + stridesX[0], + stridesY[0], + stridesZ[0] + ]; + dv1 = [ + stridesX[1] - ( S0*stridesX[0] ), + stridesY[1] - ( S0*stridesY[0] ), + stridesZ[1] - ( S0*stridesZ[0] ) + ]; + dv2 = [ + stridesX[2] - ( S1*stridesX[1] ), + stridesY[2] - ( S1*stridesY[1] ), + stridesZ[2] - ( S1*stridesZ[1] ) + ]; + dv3 = [ + stridesX[3] - ( S2*stridesX[2] ), + stridesY[3] - ( S2*stridesY[2] ), + stridesZ[3] - ( S2*stridesZ[2] ) + ]; + dv4 = [ + stridesX[4] - ( S3*stridesX[3] ), + stridesY[4] - ( S3*stridesY[3] ), + stridesZ[4] - ( S3*stridesZ[3] ) + ]; + dv5 = [ + stridesX[5] - ( S4*stridesX[4] ), + stridesY[5] - ( S4*stridesY[4] ), + stridesZ[5] - ( S4*stridesZ[4] ) + ]; + dv6 = [ // offset increment for outermost loop + stridesX[6] - ( S5*stridesX[5] ), + stridesY[6] - ( S5*stridesY[5] ), + stridesZ[6] - ( S5*stridesZ[5] ) + ]; + for ( i = 3; i < arrays.length; i++ ) { + sv = arrays[ i ].strides; + dv0.push( sv[0] ); + dv1.push( sv[1] - ( S0*sv[0] ) ); + dv2.push( sv[2] - ( S1*sv[1] ) ); + dv3.push( sv[3] - ( S2*sv[2] ) ); + dv4.push( sv[4] - ( S3*sv[3] ) ); + dv5.push( sv[5] - ( S4*sv[4] ) ); + dv6.push( sv[6] - ( S5*sv[5] ) ); + } + } + // Resolve a list of pointers to the first indexed elements in the respective ndarrays: + iv = offsets( arrays ); + + // Shallow copy the list of views to an internal array so that we can update with reshaped views without impacting the original list of views: + v = copyIndexed( views ); + + // Iterate over the loop 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++ ) { + setViewOffsets( views, iv ); + v[ 0 ] = strategyX.input( views[ 0 ] ); + v[ 1 ] = strategyY.input( views[ 1 ] ); + v[ 2 ] = strategyZ.input( views[ 2 ] ); + fcn( v, opts ); + strategyZ.output( views[ 2 ] ); + incrementOffsets( iv, dv0 ); + } + incrementOffsets( iv, dv1 ); + } + incrementOffsets( iv, dv2 ); + } + incrementOffsets( iv, dv3 ); + } + incrementOffsets( iv, dv4 ); + } + incrementOffsets( iv, dv5 ); + } + incrementOffsets( iv, dv6 ); + } +} + + +// EXPORTS // + +module.exports = kernel; diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/8d.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/8d.js new file mode 100644 index 000000000000..c82267272128 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/8d.js @@ -0,0 +1,359 @@ +/** +* @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-depth */ + +'use strict'; + +// MODULES // + +var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); +var copyIndexed = require( '@stdlib/array/base/copy-indexed' ); +var incrementOffsets = require( '@stdlib/ndarray/base/kernels/utils/increment-offsets' ); +var setViewOffsets = require( '@stdlib/ndarray/base/set-descriptor-offsets' ); +var offsets = require( '@stdlib/ndarray/base/offsets' ); + + +// MAIN // + +/** +* Applies a one-dimensional strided array function to a list of specified dimensions in two input ndarrays and assigns results to a provided output ndarray. +* +* @private +* @param {Function} fcn - wrapper for a one-dimensional strided array function +* @param {Array} arrays - ndarray descriptors +* @param {Array} views - initialized ndarray descriptors representing subarray views +* @param {Array} shape - loop dimensions +* @param {Array} stridesX - loop dimension strides for the first input ndarray +* @param {Array} stridesY - loop dimension strides for the second input ndarray +* @param {Array} stridesZ - loop dimension strides for the output ndarray +* @param {Object} strategyX - strategy for marshaling data to and from a first input ndarray view +* @param {Object} strategyY - strategy for marshaling data to and from a second input ndarray view +* @param {Object} strategyZ - strategy for marshaling data to and from an output ndarray view +* @param {Options} opts - function options +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +* var gwxpy = require( '@stdlib/blas/ext/base/ndarray/gwxpy' ); +* +* // 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( [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0 ] ); +* var zbuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* // Define the array shapes: +* var xsh = [ 1, 1, 1, 1, 1, 1, 1, 3, 2, 2 ]; +* var ysh = [ 1, 1, 1, 1, 1, 1, 1, 3, 2, 2 ]; +* var zsh = [ 1, 1, 1, 1, 1, 1, 1, 3, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 12, 12, 12, 12, 12, 12, 12, 4, 2, 1 ]; +* var sy = [ 12, 12, 12, 12, 12, 12, 12, 4, 2, 1 ]; +* var sz = [ 12, 12, 12, 12, 12, 12, 12, 4, 2, 1 ]; +* +* // Define the index offsets: +* var ox = 0; +* var oy = 0; +* var oz = 0; +* +* // Create the input ndarray descriptors: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': xsh, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* var y = { +* 'dtype': 'float64', +* 'data': ybuf, +* 'shape': ysh, +* 'strides': sy, +* 'offset': oy, +* 'order': 'row-major' +* }; +* +* // Create an output ndarray descriptor: +* var z = { +* 'dtype': 'float64', +* 'data': zbuf, +* 'shape': zsh, +* 'strides': sz, +* 'offset': oz, +* 'order': 'row-major' +* }; +* +* // Initialize ndarray descriptors representing subarray views: +* var views = [ +* { +* 'dtype': x.dtype, +* 'data': x.data, +* 'shape': [ 2, 2 ], +* 'strides': [ 2, 1 ], +* 'offset': x.offset, +* 'order': x.order +* }, +* { +* 'dtype': y.dtype, +* 'data': y.data, +* 'shape': [ 2, 2 ], +* 'strides': [ 2, 1 ], +* 'offset': y.offset, +* 'order': y.order +* }, +* { +* 'dtype': z.dtype, +* 'data': z.data, +* 'shape': [ 2, 2 ], +* 'strides': [ 2, 1 ], +* 'offset': z.offset, +* 'order': z.order +* } +* ]; +* +* // Define an input strategy: +* function inputStrategy( x ) { +* return { +* 'dtype': x.dtype, +* 'data': x.data, +* 'shape': [ 4 ], +* 'strides': [ 1 ], +* 'offset': x.offset, +* 'order': x.order +* }; +* } +* +* // Define an output strategy: +* function outputStrategy( x ) { +* return x; +* } +* +* var strategy = { +* 'input': inputStrategy, +* 'output': outputStrategy +* }; +* +* // Apply strided function: +* kernel( gwxpy, [ x, y, z ], views, [ 1, 1, 1, 1, 1, 1, 1, 3 ], [ 12, 12, 12, 12, 12, 12, 12, 4 ], [ 12, 12, 12, 12, 12, 12, 12, 4 ], [ 12, 12, 12, 12, 12, 12, 12, 4 ], strategy, strategy, strategy, {} ); +* +* var arr = ndarray2array( z.data, z.shape, z.strides, z.offset, z.order ); +* // returns [ [ [ [ [ [ [ [ [ [ 3.0, 5.0 ], [ 7.0, 9.0 ] ], [ [ 11.0, 13.0 ], [ 15.0, 17.0 ] ], [ [ 19.0, 21.0 ], [ 23.0, 25.0 ] ] ] ] ] ] ] ] ] ] +*/ +function kernel( fcn, arrays, views, shape, stridesX, stridesY, stridesZ, strategyX, strategyY, strategyZ, opts ) { // eslint-disable-line max-len, max-params, max-statements + var dv0; + var dv1; + var dv2; + var dv3; + var dv4; + var dv5; + var dv6; + var dv7; + var S0; + var S1; + var S2; + var S3; + var S4; + var S5; + var S6; + var S7; + var sv; + var iv; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + var i7; + var v; + var i; + + // Note on variable naming convention: S#, dv#, 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... + if ( isRowMajor( stridesX ) ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = shape[ 7 ]; + S1 = shape[ 6 ]; + S2 = shape[ 5 ]; + S3 = shape[ 4 ]; + S4 = shape[ 3 ]; + S5 = shape[ 2 ]; + S6 = shape[ 1 ]; + S7 = shape[ 0 ]; + dv0 = [ // offset increment for innermost loop + stridesX[7], + stridesY[7], + stridesZ[7] + ]; + dv1 = [ + stridesX[6] - ( S0*stridesX[7] ), + stridesY[6] - ( S0*stridesY[7] ), + stridesZ[6] - ( S0*stridesZ[7] ) + ]; + dv2 = [ + stridesX[5] - ( S1*stridesX[6] ), + stridesY[5] - ( S1*stridesY[6] ), + stridesZ[5] - ( S1*stridesZ[6] ) + ]; + dv3 = [ + stridesX[4] - ( S2*stridesX[5] ), + stridesY[4] - ( S2*stridesY[5] ), + stridesZ[4] - ( S2*stridesZ[5] ) + ]; + dv4 = [ + stridesX[3] - ( S3*stridesX[4] ), + stridesY[3] - ( S3*stridesY[4] ), + stridesZ[3] - ( S3*stridesZ[4] ) + ]; + dv5 = [ + stridesX[2] - ( S4*stridesX[3] ), + stridesY[2] - ( S4*stridesY[3] ), + stridesZ[2] - ( S4*stridesZ[3] ) + ]; + dv6 = [ + stridesX[1] - ( S5*stridesX[2] ), + stridesY[1] - ( S5*stridesY[2] ), + stridesZ[1] - ( S5*stridesZ[2] ) + ]; + dv7 = [ // offset increment for outermost loop + stridesX[0] - ( S6*stridesX[1] ), + stridesY[0] - ( S6*stridesY[1] ), + stridesZ[0] - ( S6*stridesZ[1] ) + ]; + for ( i = 3; i < arrays.length; i++ ) { + sv = arrays[ i ].strides; + dv0.push( sv[7] ); + dv1.push( sv[6] - ( S0*sv[7] ) ); + dv2.push( sv[5] - ( S1*sv[6] ) ); + dv3.push( sv[4] - ( S2*sv[5] ) ); + dv4.push( sv[3] - ( S3*sv[4] ) ); + dv5.push( sv[2] - ( S4*sv[3] ) ); + dv6.push( sv[1] - ( S5*sv[2] ) ); + dv7.push( sv[0] - ( S6*sv[1] ) ); + } + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = shape[ 0 ]; + S1 = shape[ 1 ]; + S2 = shape[ 2 ]; + S3 = shape[ 3 ]; + S4 = shape[ 4 ]; + S5 = shape[ 5 ]; + S6 = shape[ 6 ]; + S7 = shape[ 7 ]; + dv0 = [ // offset increment for innermost loop + stridesX[0], + stridesY[0], + stridesZ[0] + ]; + dv1 = [ + stridesX[1] - ( S0*stridesX[0] ), + stridesY[1] - ( S0*stridesY[0] ), + stridesZ[1] - ( S0*stridesZ[0] ) + ]; + dv2 = [ + stridesX[2] - ( S1*stridesX[1] ), + stridesY[2] - ( S1*stridesY[1] ), + stridesZ[2] - ( S1*stridesZ[1] ) + ]; + dv3 = [ + stridesX[3] - ( S2*stridesX[2] ), + stridesY[3] - ( S2*stridesY[2] ), + stridesZ[3] - ( S2*stridesZ[2] ) + ]; + dv4 = [ + stridesX[4] - ( S3*stridesX[3] ), + stridesY[4] - ( S3*stridesY[3] ), + stridesZ[4] - ( S3*stridesZ[3] ) + ]; + dv5 = [ + stridesX[5] - ( S4*stridesX[4] ), + stridesY[5] - ( S4*stridesY[4] ), + stridesZ[5] - ( S4*stridesZ[4] ) + ]; + dv6 = [ + stridesX[6] - ( S5*stridesX[5] ), + stridesY[6] - ( S5*stridesY[5] ), + stridesZ[6] - ( S5*stridesZ[5] ) + ]; + dv7 = [ // offset increment for outermost loop + stridesX[7] - ( S6*stridesX[6] ), + stridesY[7] - ( S6*stridesY[6] ), + stridesZ[7] - ( S6*stridesZ[6] ) + ]; + for ( i = 3; i < arrays.length; i++ ) { + sv = arrays[ i ].strides; + dv0.push( sv[0] ); + dv1.push( sv[1] - ( S0*sv[0] ) ); + dv2.push( sv[2] - ( S1*sv[1] ) ); + dv3.push( sv[3] - ( S2*sv[2] ) ); + dv4.push( sv[4] - ( S3*sv[3] ) ); + dv5.push( sv[5] - ( S4*sv[4] ) ); + dv6.push( sv[6] - ( S5*sv[5] ) ); + dv7.push( sv[7] - ( S6*sv[6] ) ); + } + } + // Resolve a list of pointers to the first indexed elements in the respective ndarrays: + iv = offsets( arrays ); + + // Shallow copy the list of views to an internal array so that we can update with reshaped views without impacting the original list of views: + v = copyIndexed( views ); + + // Iterate over the loop 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++ ) { + setViewOffsets( views, iv ); + v[ 0 ] = strategyX.input( views[ 0 ] ); + v[ 1 ] = strategyY.input( views[ 1 ] ); + v[ 2 ] = strategyZ.input( views[ 2 ] ); + fcn( v, opts ); + strategyZ.output( views[ 2 ] ); + incrementOffsets( iv, dv0 ); + } + incrementOffsets( iv, dv1 ); + } + incrementOffsets( iv, dv2 ); + } + incrementOffsets( iv, dv3 ); + } + incrementOffsets( iv, dv4 ); + } + incrementOffsets( iv, dv5 ); + } + incrementOffsets( iv, dv6 ); + } + incrementOffsets( iv, dv7 ); + } +} + + +// EXPORTS // + +module.exports = kernel; diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/9d.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/9d.js new file mode 100644 index 000000000000..8cd2c131619b --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/9d.js @@ -0,0 +1,379 @@ +/** +* @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-depth, max-len */ + +'use strict'; + +// MODULES // + +var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); +var copyIndexed = require( '@stdlib/array/base/copy-indexed' ); +var incrementOffsets = require( '@stdlib/ndarray/base/kernels/utils/increment-offsets' ); +var setViewOffsets = require( '@stdlib/ndarray/base/set-descriptor-offsets' ); +var offsets = require( '@stdlib/ndarray/base/offsets' ); + + +// MAIN // + +/** +* Applies a one-dimensional strided array function to a list of specified dimensions in two input ndarrays and assigns results to a provided output ndarray. +* +* @private +* @param {Function} fcn - wrapper for a one-dimensional strided array function +* @param {Array} arrays - ndarray descriptors +* @param {Array} views - initialized ndarray descriptors representing subarray views +* @param {Array} shape - loop dimensions +* @param {Array} stridesX - loop dimension strides for the first input ndarray +* @param {Array} stridesY - loop dimension strides for the second input ndarray +* @param {Array} stridesZ - loop dimension strides for the output ndarray +* @param {Object} strategyX - strategy for marshaling data to and from a first input ndarray view +* @param {Object} strategyY - strategy for marshaling data to and from a second input ndarray view +* @param {Object} strategyZ - strategy for marshaling data to and from an output ndarray view +* @param {Options} opts - function options +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +* var gwxpy = require( '@stdlib/blas/ext/base/ndarray/gwxpy' ); +* +* // 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( [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0 ] ); +* var zbuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* // Define the array shapes: +* var xsh = [ 1, 1, 1, 1, 1, 1, 1, 1, 3, 2, 2 ]; +* var ysh = [ 1, 1, 1, 1, 1, 1, 1, 1, 3, 2, 2 ]; +* var zsh = [ 1, 1, 1, 1, 1, 1, 1, 1, 3, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 12, 12, 12, 12, 12, 12, 12, 12, 4, 2, 1 ]; +* var sy = [ 12, 12, 12, 12, 12, 12, 12, 12, 4, 2, 1 ]; +* var sz = [ 12, 12, 12, 12, 12, 12, 12, 12, 4, 2, 1 ]; +* +* // Define the index offsets: +* var ox = 0; +* var oy = 0; +* var oz = 0; +* +* // Create the input ndarray descriptors: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': xsh, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* var y = { +* 'dtype': 'float64', +* 'data': ybuf, +* 'shape': ysh, +* 'strides': sy, +* 'offset': oy, +* 'order': 'row-major' +* }; +* +* // Create an output ndarray descriptor: +* var z = { +* 'dtype': 'float64', +* 'data': zbuf, +* 'shape': zsh, +* 'strides': sz, +* 'offset': oz, +* 'order': 'row-major' +* }; +* +* // Initialize ndarray descriptors representing subarray views: +* var views = [ +* { +* 'dtype': x.dtype, +* 'data': x.data, +* 'shape': [ 2, 2 ], +* 'strides': [ 2, 1 ], +* 'offset': x.offset, +* 'order': x.order +* }, +* { +* 'dtype': y.dtype, +* 'data': y.data, +* 'shape': [ 2, 2 ], +* 'strides': [ 2, 1 ], +* 'offset': y.offset, +* 'order': y.order +* }, +* { +* 'dtype': z.dtype, +* 'data': z.data, +* 'shape': [ 2, 2 ], +* 'strides': [ 2, 1 ], +* 'offset': z.offset, +* 'order': z.order +* } +* ]; +* +* // Define an input strategy: +* function inputStrategy( x ) { +* return { +* 'dtype': x.dtype, +* 'data': x.data, +* 'shape': [ 4 ], +* 'strides': [ 1 ], +* 'offset': x.offset, +* 'order': x.order +* }; +* } +* +* // Define an output strategy: +* function outputStrategy( x ) { +* return x; +* } +* +* var strategy = { +* 'input': inputStrategy, +* 'output': outputStrategy +* }; +* +* // Apply strided function: +* kernel( gwxpy, [ x, y, z ], views, [ 1, 1, 1, 1, 1, 1, 1, 1, 3 ], [ 12, 12, 12, 12, 12, 12, 12, 12, 4 ], [ 12, 12, 12, 12, 12, 12, 12, 12, 4 ], [ 12, 12, 12, 12, 12, 12, 12, 12, 4 ], strategy, strategy, strategy, {} ); +* +* var arr = ndarray2array( z.data, z.shape, z.strides, z.offset, z.order ); +* // returns [ [ [ [ [ [ [ [ [ [ [ 3.0, 5.0 ], [ 7.0, 9.0 ] ], [ [ 11.0, 13.0 ], [ 15.0, 17.0 ] ], [ [ 19.0, 21.0 ], [ 23.0, 25.0 ] ] ] ] ] ] ] ] ] ] ] +*/ +function kernel( fcn, arrays, views, shape, stridesX, stridesY, stridesZ, strategyX, strategyY, strategyZ, opts ) { // eslint-disable-line max-params, max-statements + var dv0; + var dv1; + var dv2; + var dv3; + var dv4; + var dv5; + var dv6; + var dv7; + var dv8; + var S0; + var S1; + var S2; + var S3; + var S4; + var S5; + var S6; + var S7; + var S8; + var sv; + var iv; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + var i7; + var i8; + var v; + var i; + + // Note on variable naming convention: S#, dv#, 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... + if ( isRowMajor( stridesX ) ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = shape[ 8 ]; + S1 = shape[ 7 ]; + S2 = shape[ 6 ]; + S3 = shape[ 5 ]; + S4 = shape[ 4 ]; + S5 = shape[ 3 ]; + S6 = shape[ 2 ]; + S7 = shape[ 1 ]; + S8 = shape[ 0 ]; + dv0 = [ // offset increment for innermost loop + stridesX[8], + stridesY[8], + stridesZ[8] + ]; + dv1 = [ + stridesX[7] - ( S0*stridesX[8] ), + stridesY[7] - ( S0*stridesY[8] ), + stridesZ[7] - ( S0*stridesZ[8] ) + ]; + dv2 = [ + stridesX[6] - ( S1*stridesX[7] ), + stridesY[6] - ( S1*stridesY[7] ), + stridesZ[6] - ( S1*stridesZ[7] ) + ]; + dv3 = [ + stridesX[5] - ( S2*stridesX[6] ), + stridesY[5] - ( S2*stridesY[6] ), + stridesZ[5] - ( S2*stridesZ[6] ) + ]; + dv4 = [ + stridesX[4] - ( S3*stridesX[5] ), + stridesY[4] - ( S3*stridesY[5] ), + stridesZ[4] - ( S3*stridesZ[5] ) + ]; + dv5 = [ + stridesX[3] - ( S4*stridesX[4] ), + stridesY[3] - ( S4*stridesY[4] ), + stridesZ[3] - ( S4*stridesZ[4] ) + ]; + dv6 = [ + stridesX[2] - ( S5*stridesX[3] ), + stridesY[2] - ( S5*stridesY[3] ), + stridesZ[2] - ( S5*stridesZ[3] ) + ]; + dv7 = [ + stridesX[1] - ( S6*stridesX[2] ), + stridesY[1] - ( S6*stridesY[2] ), + stridesZ[1] - ( S6*stridesZ[2] ) + ]; + dv8 = [ // offset increment for outermost loop + stridesX[0] - ( S7*stridesX[1] ), + stridesY[0] - ( S7*stridesY[1] ), + stridesZ[0] - ( S7*stridesZ[1] ) + ]; + for ( i = 3; i < arrays.length; i++ ) { + sv = arrays[ i ].strides; + dv0.push( sv[8] ); + dv1.push( sv[7] - ( S0*sv[8] ) ); + dv2.push( sv[6] - ( S1*sv[7] ) ); + dv3.push( sv[5] - ( S2*sv[6] ) ); + dv4.push( sv[4] - ( S3*sv[5] ) ); + dv5.push( sv[3] - ( S4*sv[4] ) ); + dv6.push( sv[2] - ( S5*sv[3] ) ); + dv7.push( sv[1] - ( S6*sv[2] ) ); + dv8.push( sv[0] - ( S7*sv[1] ) ); + } + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = shape[ 0 ]; + S1 = shape[ 1 ]; + S2 = shape[ 2 ]; + S3 = shape[ 3 ]; + S4 = shape[ 4 ]; + S5 = shape[ 5 ]; + S6 = shape[ 6 ]; + S7 = shape[ 7 ]; + S8 = shape[ 8 ]; + dv0 = [ // offset increment for innermost loop + stridesX[0], + stridesY[0], + stridesZ[0] + ]; + dv1 = [ + stridesX[1] - ( S0*stridesX[0] ), + stridesY[1] - ( S0*stridesY[0] ), + stridesZ[1] - ( S0*stridesZ[0] ) + ]; + dv2 = [ + stridesX[2] - ( S1*stridesX[1] ), + stridesY[2] - ( S1*stridesY[1] ), + stridesZ[2] - ( S1*stridesZ[1] ) + ]; + dv3 = [ + stridesX[3] - ( S2*stridesX[2] ), + stridesY[3] - ( S2*stridesY[2] ), + stridesZ[3] - ( S2*stridesZ[2] ) + ]; + dv4 = [ + stridesX[4] - ( S3*stridesX[3] ), + stridesY[4] - ( S3*stridesY[3] ), + stridesZ[4] - ( S3*stridesZ[3] ) + ]; + dv5 = [ + stridesX[5] - ( S4*stridesX[4] ), + stridesY[5] - ( S4*stridesY[4] ), + stridesZ[5] - ( S4*stridesZ[4] ) + ]; + dv6 = [ + stridesX[6] - ( S5*stridesX[5] ), + stridesY[6] - ( S5*stridesY[5] ), + stridesZ[6] - ( S5*stridesZ[5] ) + ]; + dv7 = [ + stridesX[7] - ( S6*stridesX[6] ), + stridesY[7] - ( S6*stridesY[6] ), + stridesZ[7] - ( S6*stridesZ[6] ) + ]; + dv8 = [ // offset increment for outermost loop + stridesX[8] - ( S7*stridesX[7] ), + stridesY[8] - ( S7*stridesY[7] ), + stridesZ[8] - ( S7*stridesZ[7] ) + ]; + for ( i = 3; i < arrays.length; i++ ) { + sv = arrays[ i ].strides; + dv0.push( sv[0] ); + dv1.push( sv[1] - ( S0*sv[0] ) ); + dv2.push( sv[2] - ( S1*sv[1] ) ); + dv3.push( sv[3] - ( S2*sv[2] ) ); + dv4.push( sv[4] - ( S3*sv[3] ) ); + dv5.push( sv[5] - ( S4*sv[4] ) ); + dv6.push( sv[6] - ( S5*sv[5] ) ); + dv7.push( sv[7] - ( S6*sv[6] ) ); + dv8.push( sv[8] - ( S7*sv[7] ) ); + } + } + // Resolve a list of pointers to the first indexed elements in the respective ndarrays: + iv = offsets( arrays ); + + // Shallow copy the list of views to an internal array so that we can update with reshaped views without impacting the original list of views: + v = copyIndexed( views ); + + // Iterate over the loop 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++ ) { + setViewOffsets( views, iv ); + v[ 0 ] = strategyX.input( views[ 0 ] ); + v[ 1 ] = strategyY.input( views[ 1 ] ); + v[ 2 ] = strategyZ.input( views[ 2 ] ); + fcn( v, opts ); + strategyZ.output( views[ 2 ] ); + incrementOffsets( iv, dv0 ); + } + incrementOffsets( iv, dv1 ); + } + incrementOffsets( iv, dv2 ); + } + incrementOffsets( iv, dv3 ); + } + incrementOffsets( iv, dv4 ); + } + incrementOffsets( iv, dv5 ); + } + incrementOffsets( iv, dv6 ); + } + incrementOffsets( iv, dv7 ); + } + incrementOffsets( iv, dv8 ); + } +} + + +// EXPORTS // + +module.exports = kernel; diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/index.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/index.js new file mode 100644 index 000000000000..e6b643e9847c --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/index.js @@ -0,0 +1,175 @@ +/** +* @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 one-dimensional strided array function to two input ndarrays and assigning results to an output ndarray. +* +* @module @stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +* var gwxpy = require( '@stdlib/blas/ext/base/ndarray/gwxpy' ); +* var kernel = require( '@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked' ); +* +* // 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( [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0 ] ); +* var zbuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* // Define the array shapes: +* var xsh = [ 1, 3, 2, 2 ]; +* var ysh = [ 1, 3, 2, 2 ]; +* var zsh = [ 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 ]; +* +* // Define the index offsets: +* var ox = 0; +* var oy = 0; +* var oz = 0; +* +* // Create the input ndarray descriptors: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': xsh, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* var y = { +* 'dtype': 'float64', +* 'data': ybuf, +* 'shape': ysh, +* 'strides': sy, +* 'offset': oy, +* 'order': 'row-major' +* }; +* +* // Create an output ndarray descriptor: +* var z = { +* 'dtype': 'float64', +* 'data': zbuf, +* 'shape': zsh, +* 'strides': sz, +* 'offset': oz, +* 'order': 'row-major' +* }; +* +* // Initialize ndarray descriptors representing subarray views: +* var views = [ +* { +* 'dtype': x.dtype, +* 'data': x.data, +* 'shape': [ 2, 2 ], +* 'strides': [ 2, 1 ], +* 'offset': x.offset, +* 'order': x.order +* }, +* { +* 'dtype': y.dtype, +* 'data': y.data, +* 'shape': [ 2, 2 ], +* 'strides': [ 2, 1 ], +* 'offset': y.offset, +* 'order': y.order +* }, +* { +* 'dtype': z.dtype, +* 'data': z.data, +* 'shape': [ 2, 2 ], +* 'strides': [ 2, 1 ], +* 'offset': z.offset, +* 'order': z.order +* } +* ]; +* +* // Define an input strategy: +* function inputStrategy( x ) { +* return { +* 'dtype': x.dtype, +* 'data': x.data, +* 'shape': [ 4 ], +* 'strides': [ 1 ], +* 'offset': x.offset, +* 'order': x.order +* }; +* } +* +* // Define an output strategy: +* function outputStrategy( x ) { +* return x; +* } +* +* var strategy = { +* 'input': inputStrategy, +* 'output': outputStrategy +* }; +* +* // Resolve a kernel: +* var f = kernel( 2 ); +* +* // Apply strided function: +* f( gwxpy, [ x, y, z ], views, [ 1, 3 ], [ 12, 4 ], [ 12, 4 ], [ 12, 4 ], strategy, strategy, strategy, {} ); +* +* var arr = ndarray2array( z.data, z.shape, z.strides, z.offset, z.order ); +* // returns [ [ [ [ 3.0, 5.0 ], [ 7.0, 9.0 ] ], [ [ 11.0, 13.0 ], [ 15.0, 17.0 ] ], [ [ 19.0, 21.0 ], [ 23.0, 25.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/binary-strided1d/unblocked/lib/main.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/main.js new file mode 100644 index 000000000000..879692c18a68 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/lib/main.js @@ -0,0 +1,185 @@ +/** +* @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 one-dimensional strided array function to two input ndarrays and assigning results to an output ndarray. +* +* @param {integer} ndims - number of loop dimensions +* @returns {(Function|null)} kernel function or null +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +* var gwxpy = require( '@stdlib/blas/ext/base/ndarray/gwxpy' ); +* +* // 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( [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0 ] ); +* var zbuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* // Define the array shapes: +* var xsh = [ 1, 3, 2, 2 ]; +* var ysh = [ 1, 3, 2, 2 ]; +* var zsh = [ 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 ]; +* +* // Define the index offsets: +* var ox = 0; +* var oy = 0; +* var oz = 0; +* +* // Create the input ndarray descriptors: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': xsh, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* var y = { +* 'dtype': 'float64', +* 'data': ybuf, +* 'shape': ysh, +* 'strides': sy, +* 'offset': oy, +* 'order': 'row-major' +* }; +* +* // Create an output ndarray descriptor: +* var z = { +* 'dtype': 'float64', +* 'data': zbuf, +* 'shape': zsh, +* 'strides': sz, +* 'offset': oz, +* 'order': 'row-major' +* }; +* +* // Initialize ndarray descriptors representing subarray views: +* var views = [ +* { +* 'dtype': x.dtype, +* 'data': x.data, +* 'shape': [ 2, 2 ], +* 'strides': [ 2, 1 ], +* 'offset': x.offset, +* 'order': x.order +* }, +* { +* 'dtype': y.dtype, +* 'data': y.data, +* 'shape': [ 2, 2 ], +* 'strides': [ 2, 1 ], +* 'offset': y.offset, +* 'order': y.order +* }, +* { +* 'dtype': z.dtype, +* 'data': z.data, +* 'shape': [ 2, 2 ], +* 'strides': [ 2, 1 ], +* 'offset': z.offset, +* 'order': z.order +* } +* ]; +* +* // Define an input strategy: +* function inputStrategy( x ) { +* return { +* 'dtype': x.dtype, +* 'data': x.data, +* 'shape': [ 4 ], +* 'strides': [ 1 ], +* 'offset': x.offset, +* 'order': x.order +* }; +* } +* +* // Define an output strategy: +* function outputStrategy( x ) { +* return x; +* } +* +* var strategy = { +* 'input': inputStrategy, +* 'output': outputStrategy +* }; +* +* // Resolve a kernel: +* var f = kernel( 2 ); +* +* // Apply strided function: +* f( gwxpy, [ x, y, z ], views, [ 1, 3 ], [ 12, 4 ], [ 12, 4 ], [ 12, 4 ], strategy, strategy, strategy, {} ); +* +* var arr = ndarray2array( z.data, z.shape, z.strides, z.offset, z.order ); +* // returns [ [ [ [ 3.0, 5.0 ], [ 7.0, 9.0 ] ], [ [ 11.0, 13.0 ], [ 15.0, 17.0 ] ], [ [ 19.0, 21.0 ], [ 23.0, 25.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/binary-strided1d/unblocked/package.json b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/package.json new file mode 100644 index 000000000000..b3dfe425c197 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/package.json @@ -0,0 +1,65 @@ +{ + "name": "@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked", + "version": "0.0.0", + "description": "Return a kernel for applying a one-dimensional strided array function to two input ndarrays and assigning results to 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", + "strided", + "array", + "ndarray", + "binary", + "apply", + "cumulative", + "accumulate", + "accumulation", + "vector", + "kernel" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/test/test.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/test/test.js new file mode 100644 index 000000000000..053851cfb7f7 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/test/test.js @@ -0,0 +1,35 @@ +/** +* @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 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(); +}); + +// FIXME: add tests From 754e3bc3b4e317f5b17e9e7b235b9b9d7e1ef0c5 Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 29 Aug 2026 17:12:56 -0700 Subject: [PATCH 2/4] style: fix missing linebreak Signed-off-by: Athan --- .../kernels/generic/binary-strided1d/unblocked/docs/repl.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/docs/repl.txt index ef8d785a8002..045283ba0e80 100644 --- a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/docs/repl.txt +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/docs/repl.txt @@ -1,3 +1,4 @@ + {{alias}}( ndims ) Returns a kernel for applying a one-dimensional strided array function to two input ndarrays and assigning results to an output ndarray. From b3d5c6aa0e602275e61bd2d023d22bd488d4112a Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 29 Aug 2026 17:15:30 -0700 Subject: [PATCH 3/4] docs: rename parameters Signed-off-by: Athan --- .../binary-strided1d/unblocked/docs/repl.txt | 88 +++++++++---------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/docs/repl.txt index 045283ba0e80..e443b914307b 100644 --- a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/docs/repl.txt +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/docs/repl.txt @@ -41,7 +41,7 @@ -{{alias}}.kernel0d( fcn, arr, views, sh, sx, sy, sz, stX, stY, stZ, opts ) +{{alias}}.kernel0d( fcn, arr, views, sh, sx, sy, sz, stx, sty, stz, opts ) Applies a one-dimensional strided array function to a list of specified dimensions in two input ndarrays and assigns results to a provided output ndarray. @@ -74,20 +74,20 @@ sz: Array Loop dimension strides for the output ndarray. - stX: Object + stx: Object Strategy for marshaling data to and from a first input ndarray view. - stY: Object + sty: Object Strategy for marshaling data to and from a second input ndarray view. - stZ: Object + stz: Object Strategy for marshaling data to and from an output ndarray view. opts: Object Function options which are passed through to `fcn`. -{{alias}}.kernel1d( fcn, arr, views, sh, sx, sy, sz, stX, stY, stZ, opts ) +{{alias}}.kernel1d( fcn, arr, views, sh, sx, sy, sz, stx, sty, stz, opts ) Applies a one-dimensional strided array function to a list of specified dimensions in two input ndarrays and assigns results to a provided output ndarray. @@ -116,20 +116,20 @@ sz: Array Loop dimension strides for the output ndarray. - stX: Object + stx: Object Strategy for marshaling data to and from a first input ndarray view. - stY: Object + sty: Object Strategy for marshaling data to and from a second input ndarray view. - stZ: Object + stz: Object Strategy for marshaling data to and from an output ndarray view. opts: Object Function options which are passed through to `fcn`. -{{alias}}.kernel2d( fcn, arr, views, sh, sx, sy, sz, stX, stY, stZ, opts ) +{{alias}}.kernel2d( fcn, arr, views, sh, sx, sy, sz, stx, sty, stz, opts ) Applies a one-dimensional strided array function to a list of specified dimensions in two input ndarrays and assigns results to a provided output ndarray. @@ -158,20 +158,20 @@ sz: Array Loop dimension strides for the output ndarray. - stX: Object + stx: Object Strategy for marshaling data to and from a first input ndarray view. - stY: Object + sty: Object Strategy for marshaling data to and from a second input ndarray view. - stZ: Object + stz: Object Strategy for marshaling data to and from an output ndarray view. opts: Object Function options which are passed through to `fcn`. -{{alias}}.kernel3d( fcn, arr, views, sh, sx, sy, sz, stX, stY, stZ, opts ) +{{alias}}.kernel3d( fcn, arr, views, sh, sx, sy, sz, stx, sty, stz, opts ) Applies a one-dimensional strided array function to a list of specified dimensions in two input ndarrays and assigns results to a provided output ndarray. @@ -200,20 +200,20 @@ sz: Array Loop dimension strides for the output ndarray. - stX: Object + stx: Object Strategy for marshaling data to and from a first input ndarray view. - stY: Object + sty: Object Strategy for marshaling data to and from a second input ndarray view. - stZ: Object + stz: Object Strategy for marshaling data to and from an output ndarray view. opts: Object Function options which are passed through to `fcn`. -{{alias}}.kernel4d( fcn, arr, views, sh, sx, sy, sz, stX, stY, stZ, opts ) +{{alias}}.kernel4d( fcn, arr, views, sh, sx, sy, sz, stx, sty, stz, opts ) Applies a one-dimensional strided array function to a list of specified dimensions in two input ndarrays and assigns results to a provided output ndarray. @@ -242,20 +242,20 @@ sz: Array Loop dimension strides for the output ndarray. - stX: Object + stx: Object Strategy for marshaling data to and from a first input ndarray view. - stY: Object + sty: Object Strategy for marshaling data to and from a second input ndarray view. - stZ: Object + stz: Object Strategy for marshaling data to and from an output ndarray view. opts: Object Function options which are passed through to `fcn`. -{{alias}}.kernel5d( fcn, arr, views, sh, sx, sy, sz, stX, stY, stZ, opts ) +{{alias}}.kernel5d( fcn, arr, views, sh, sx, sy, sz, stx, sty, stz, opts ) Applies a one-dimensional strided array function to a list of specified dimensions in two input ndarrays and assigns results to a provided output ndarray. @@ -284,20 +284,20 @@ sz: Array Loop dimension strides for the output ndarray. - stX: Object + stx: Object Strategy for marshaling data to and from a first input ndarray view. - stY: Object + sty: Object Strategy for marshaling data to and from a second input ndarray view. - stZ: Object + stz: Object Strategy for marshaling data to and from an output ndarray view. opts: Object Function options which are passed through to `fcn`. -{{alias}}.kernel6d( fcn, arr, views, sh, sx, sy, sz, stX, stY, stZ, opts ) +{{alias}}.kernel6d( fcn, arr, views, sh, sx, sy, sz, stx, sty, stz, opts ) Applies a one-dimensional strided array function to a list of specified dimensions in two input ndarrays and assigns results to a provided output ndarray. @@ -326,20 +326,20 @@ sz: Array Loop dimension strides for the output ndarray. - stX: Object + stx: Object Strategy for marshaling data to and from a first input ndarray view. - stY: Object + sty: Object Strategy for marshaling data to and from a second input ndarray view. - stZ: Object + stz: Object Strategy for marshaling data to and from an output ndarray view. opts: Object Function options which are passed through to `fcn`. -{{alias}}.kernel7d( fcn, arr, views, sh, sx, sy, sz, stX, stY, stZ, opts ) +{{alias}}.kernel7d( fcn, arr, views, sh, sx, sy, sz, stx, sty, stz, opts ) Applies a one-dimensional strided array function to a list of specified dimensions in two input ndarrays and assigns results to a provided output ndarray. @@ -368,20 +368,20 @@ sz: Array Loop dimension strides for the output ndarray. - stX: Object + stx: Object Strategy for marshaling data to and from a first input ndarray view. - stY: Object + sty: Object Strategy for marshaling data to and from a second input ndarray view. - stZ: Object + stz: Object Strategy for marshaling data to and from an output ndarray view. opts: Object Function options which are passed through to `fcn`. -{{alias}}.kernel8d( fcn, arr, views, sh, sx, sy, sz, stX, stY, stZ, opts ) +{{alias}}.kernel8d( fcn, arr, views, sh, sx, sy, sz, stx, sty, stz, opts ) Applies a one-dimensional strided array function to a list of specified dimensions in two input ndarrays and assigns results to a provided output ndarray. @@ -410,20 +410,20 @@ sz: Array Loop dimension strides for the output ndarray. - stX: Object + stx: Object Strategy for marshaling data to and from a first input ndarray view. - stY: Object + sty: Object Strategy for marshaling data to and from a second input ndarray view. - stZ: Object + stz: Object Strategy for marshaling data to and from an output ndarray view. opts: Object Function options which are passed through to `fcn`. -{{alias}}.kernel9d( fcn, arr, views, sh, sx, sy, sz, stX, stY, stZ, opts ) +{{alias}}.kernel9d( fcn, arr, views, sh, sx, sy, sz, stx, sty, stz, opts ) Applies a one-dimensional strided array function to a list of specified dimensions in two input ndarrays and assigns results to a provided output ndarray. @@ -452,20 +452,20 @@ sz: Array Loop dimension strides for the output ndarray. - stX: Object + stx: Object Strategy for marshaling data to and from a first input ndarray view. - stY: Object + sty: Object Strategy for marshaling data to and from a second input ndarray view. - stZ: Object + stz: Object Strategy for marshaling data to and from an output ndarray view. opts: Object Function options which are passed through to `fcn`. -{{alias}}.kernel10d( fcn, arr, views, sh, sx, sy, sz, stX, stY, stZ, opts ) +{{alias}}.kernel10d( fcn, arr, views, sh, sx, sy, sz, stx, sty, stz, opts ) Applies a one-dimensional strided array function to a list of specified dimensions in two input ndarrays and assigns results to a provided output ndarray. @@ -494,13 +494,13 @@ sz: Array Loop dimension strides for the output ndarray. - stX: Object + stx: Object Strategy for marshaling data to and from a first input ndarray view. - stY: Object + sty: Object Strategy for marshaling data to and from a second input ndarray view. - stZ: Object + stz: Object Strategy for marshaling data to and from an output ndarray view. opts: Object From ce651154037237e180d2f76bde163ce5ffbba02c Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 29 Aug 2026 17:29:56 -0700 Subject: [PATCH 4/4] docs: fix signatures Signed-off-by: Athan --- .../binary-strided1d/unblocked/README.md | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/README.md b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/README.md index 02a8d233eaca..3294ab75e920 100644 --- a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/README.md +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/binary-strided1d/unblocked/README.md @@ -185,7 +185,7 @@ The returned function iterates over ndarray elements according to the memory lay -#### kernel.kernel.kernel0d( fcn, arrays, views, shape, stridesX, strideY, strideZ, strategyX, strategyY, strategyZ, options ) +#### kernel.kernel0d( fcn, arrays, views, shape, stridesX, strideY, strideZ, strategyX, strategyY, strategyZ, options ) @@ -294,7 +294,7 @@ The `views`, `shape`, `stridesX`, `stridesY`, and `stridesZ` parameters are unus -#### kernel.kernel.kernel1d( fcn, arrays, views, shape, stridesX, strideY, strideZ, strategyX, strategyY, strategyZ, options ) +#### kernel.kernel1d( fcn, arrays, views, shape, stridesX, strideY, strideZ, strategyX, strategyY, strategyZ, options ) @@ -429,7 +429,7 @@ The function has the following parameters: -#### kernel.kernel.kernel2d( fcn, arrays, views, shape, stridesX, strideY, strideZ, strategyX, strategyY, strategyZ, options ) +#### kernel.kernel2d( fcn, arrays, views, shape, stridesX, strideY, strideZ, strategyX, strategyY, strategyZ, options ) @@ -564,7 +564,7 @@ The function has the following parameters: -#### kernel.kernel.kernel3d( fcn, arrays, views, shape, stridesX, strideY, strideZ, strategyX, strategyY, strategyZ, options ) +#### kernel.kernel3d( fcn, arrays, views, shape, stridesX, strideY, strideZ, strategyX, strategyY, strategyZ, options ) @@ -699,7 +699,7 @@ The function has the following parameters: -#### kernel.kernel.kernel4d( fcn, arrays, views, shape, stridesX, strideY, strideZ, strategyX, strategyY, strategyZ, options ) +#### kernel.kernel4d( fcn, arrays, views, shape, stridesX, strideY, strideZ, strategyX, strategyY, strategyZ, options ) @@ -834,7 +834,7 @@ The function has the following parameters: -#### kernel.kernel.kernel5d( fcn, arrays, views, shape, stridesX, strideY, strideZ, strategyX, strategyY, strategyZ, options ) +#### kernel.kernel5d( fcn, arrays, views, shape, stridesX, strideY, strideZ, strategyX, strategyY, strategyZ, options ) @@ -969,7 +969,7 @@ The function has the following parameters: -#### kernel.kernel.kernel6d( fcn, arrays, views, shape, stridesX, strideY, strideZ, strategyX, strategyY, strategyZ, options ) +#### kernel.kernel6d( fcn, arrays, views, shape, stridesX, strideY, strideZ, strategyX, strategyY, strategyZ, options ) @@ -1104,7 +1104,7 @@ The function has the following parameters: -#### kernel.kernel.kernel7d( fcn, arrays, views, shape, stridesX, strideY, strideZ, strategyX, strategyY, strategyZ, options ) +#### kernel.kernel7d( fcn, arrays, views, shape, stridesX, strideY, strideZ, strategyX, strategyY, strategyZ, options ) @@ -1239,7 +1239,7 @@ The function has the following parameters: -#### kernel.kernel.kernel8d( fcn, arrays, views, shape, stridesX, strideY, strideZ, strategyX, strategyY, strategyZ, options ) +#### kernel.kernel8d( fcn, arrays, views, shape, stridesX, strideY, strideZ, strategyX, strategyY, strategyZ, options ) @@ -1374,7 +1374,7 @@ The function has the following parameters: -#### kernel.kernel.kernel9d( fcn, arrays, views, shape, stridesX, strideY, strideZ, strategyX, strategyY, strategyZ, options ) +#### kernel.kernel9d( fcn, arrays, views, shape, stridesX, strideY, strideZ, strategyX, strategyY, strategyZ, options ) @@ -1509,7 +1509,7 @@ The function has the following parameters: -#### kernel.kernel.kernel10d( fcn, arrays, views, shape, stridesX, strideY, strideZ, strategyX, strategyY, strategyZ, options ) +#### kernel.kernel10d( fcn, arrays, views, shape, stridesX, strideY, strideZ, strategyX, strategyY, strategyZ, options )