From 2836e0dc7ce265b5bc969ff78e7e9ae1f62649cc Mon Sep 17 00:00:00 2001 From: Jaysukh-409 Date: Mon, 15 Jul 2024 16:02:32 +0530 Subject: [PATCH 01/34] chore: create folder structure and add example --- .../@stdlib/ndarray/base/mskfilter/README.md | 78 ++++++++++++++ .../ndarray/base/mskfilter/lib/index.js | 84 +++++++++++++++ .../ndarray/base/mskfilter/lib/main.js | 100 ++++++++++++++++++ .../ndarray/base/mskfilter/manifest.json | 0 .../ndarray/base/mskfilter/package.json | 63 +++++++++++ 5 files changed, 325 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/README.md create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/index.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/manifest.json create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/package.json diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/README.md b/lib/node_modules/@stdlib/ndarray/base/mskfilter/README.md new file mode 100644 index 00000000000..9cd04e83cd1 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/README.md @@ -0,0 +1,78 @@ + + +# mskfilter + +> Apply a mask to a provided input ndarray and assigns to one-dimensional output ndarray. + +
+ +
+ + + +
+ +## Usage + +```javascript +var mskfilter = require( '@stdlib/ndarray/base/mskfilter' ); +``` + +#### assign ( arrays ) + +Apply a mask to a provided input ndarray and assigns to one-dimensional output ndarray. + +```javascript +``` + +The function accepts the following arguments: + +- **arrays**: array-like object containing input ndarray, mask ndarray and one dimensional output ndarray. + +Each provided ndarray should be an object with the following properties: + +- **dtype**: data type. +- **data**: data buffer. +- **shape**: dimensions. +- **strides**: stride lengths. +- **offset**: index offset. +- **order**: specifies whether an ndarray is row-major (C-style) or column major (Fortran-style). + +
+ + + +
+ +
+ + + +
+ +## Examples + +```javascript +``` + +
+ + \ No newline at end of file diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/index.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/index.js new file mode 100644 index 00000000000..21a98b3c2b2 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/index.js @@ -0,0 +1,84 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Apply a mask to a provided input ndarray and assigns to one-dimensional output ndarray. +* +* @module @stdlib/ndarray/base/mskfilter +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var mskfilter = require( '@stdlib/ndarray/base/mskfilter' ); +* +* // 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 mbuf = new Float64Array( [ 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 ] ); +* +* // Define the shape of the input and mask arrays: +* var shape = [ 3, 1, 2 ]; +* +* // Define the array strides: +* var sx = [ 4, 4, 1 ]; +* +* // Define the index offsets: +* var ox = 0; +* var om = 0; +* +* // Create the input, mask and output ndarray-like objects: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* var mask = { +* 'dtype': 'float64', +* 'data': mbuf, +* 'shape': shape, +* 'strides': sy, +* 'offset': om, +* 'order': 'row-major' +* }; +* var out = { +* 'dtype': 'float64', +* 'data': new Float64Array( 4 ), +* 'shape': [ 4 ], +* 'strides': [ 1 ], +* 'offset': 0, +* 'order': 'row-major' +* }; +* +* // Copy elements: +* mskfilter( [ x, mask, out ] ); +* +* console.log( out.data ); +* // => [ 1.0, 5.0, 9.0, 11.0 ] +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; \ No newline at end of file diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js new file mode 100644 index 00000000000..69b4739b1f9 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js @@ -0,0 +1,100 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + + +// VARIABLES // + + +// MAIN // + +/** +* Apply a mask to a provided input ndarray and assigns to one-dimensional output ndarray. +* +* ## Notes +* +* - Each provided ndarray should be an `object` with the following properties: +* +* - **dtype**: data type. +* - **data**: data buffer. +* - **shape**: dimensions. +* - **strides**: stride lengths. +* - **offset**: index offset. +* - **order**: specifies whether an ndarray is row-major (C-style) or column major (Fortran-style). +* +* @param {ArrayLikeObject} arrays - array-like object containing input array, mask array and one output array +* @throws {Error} input and mask arrays must have the same shape +* @throws {Error} output array must have the one dimensional shape +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var mskfilter = require( '@stdlib/ndarray/base/mskfilter' ); +* +* // 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 mbuf = new Float64Array( [ 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 ] ); +* +* // Define the shape of the input and mask arrays: +* var shape = [ 3, 1, 2 ]; +* +* // Define the array strides: +* var s = [ 4, 4, 1 ]; +* +* // Define the index offsets: +* var ox = 0; +* var om = 0; +* +* // Create the input, mask and output ndarray-like objects: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': s, +* 'offset': ox, +* 'order': 'row-major' +* }; +* var mask = { +* 'dtype': 'float64', +* 'data': mbuf, +* 'shape': shape, +* 'strides': s, +* 'offset': om, +* 'order': 'row-major' +* }; +* var out = { +* 'dtype': 'float64', +* 'data': new Float64Array( 4 ), +* 'shape': [ 4 ], +* 'strides': [ 1 ], +* 'offset': 0, +* 'order': 'row-major' +* }; +* +* // Copy elements: +* mskfilter( [ x, mask, out ] ); +* +* console.log( out.data ); +* // => [ 1.0, 5.0, 9.0, 11.0 ] +*/ +function mskfilter( arrays ) { + +} \ No newline at end of file diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/manifest.json b/lib/node_modules/@stdlib/ndarray/base/mskfilter/manifest.json new file mode 100644 index 00000000000..e69de29bb2d diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/package.json b/lib/node_modules/@stdlib/ndarray/base/mskfilter/package.json new file mode 100644 index 00000000000..d039c1cfa33 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/package.json @@ -0,0 +1,63 @@ +{ + "name": "@stdlib/ndarray/base/mskfilter", + "version": "0.0.0", + "description": "Apply a mask to a provided input ndarray and assigns to one-dimensional 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": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "include": "./include", + "lib": "./lib", + "scripts": "./scripts", + "src": "./src", + "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", + "mskfilter" + ], + "__stdlib__": {} + } \ No newline at end of file From 67dfb5225564f0ecf92f52a43cda44f2ec9d49e1 Mon Sep 17 00:00:00 2001 From: Jaysukh-409 Date: Mon, 29 Jul 2024 23:54:05 +0530 Subject: [PATCH 02/34] feat: add kernels for 0d ndarray --- .../@stdlib/ndarray/base/mskfilter/lib/0d.js | 32 +++++++ .../base/mskfilter/lib/0d_accessors.js | 32 +++++++ .../ndarray/base/mskfilter/lib/main.js | 88 ++++++++++++++++++- 3 files changed, 148 insertions(+), 4 deletions(-) create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/0d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/0d_accessors.js diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/0d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/0d.js new file mode 100644 index 00000000000..5c3056b3b1e --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/0d.js @@ -0,0 +1,32 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MAIN // + +function mskfilter0d( x, mask, y ) { + if ( mask.data[ mask.offset ] ) { + y.data[ y.offset ] = x.data[ x.offset ]; + } +} + + +// EXPORTS // + +module.exports = mskfilter0d; \ No newline at end of file diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/0d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/0d_accessors.js new file mode 100644 index 00000000000..56f6131f797 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/0d_accessors.js @@ -0,0 +1,32 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MAIN // + +function accessor_mskfilter0d( x, mask, y ) { + if ( mask.accessor[ 0 ]( mask.data, mask.offset ) ) { + y.accessor[ 1 ]( y.data, y.offset, x.accessor[ 0 ]( x.data, x.offset ) ); + } +} + + +// EXPORTS // + +module.exports = accessor_mskfilter0d; \ No newline at end of file diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js index 69b4739b1f9..5267197d11c 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js @@ -21,9 +21,34 @@ // MODULES // +var ndarray2object = require( '@stdlib/ndarray/base/ndarraylike2object' ); +var format = require( '@stdlib/string/format' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var accessor_mskfilter0d = require( './0d_accessors.js' ); +var mskfilter0d = require( './0d.js' ); + // VARIABLES // +var MSKFILTER = [ + mskfilter0d, +]; + +var ACCESSOR_MSKFILTER = [ + accessor_mskfilter0d, +]; + +var BLOCKED_MSKFILTER = [ + +]; + +var BLOCKED_ACCESSOR_MSKFILTER = [ + +]; + +var MAX_DIMS = MSKFILTER.length - 1; + + // MAIN // /** @@ -40,9 +65,10 @@ * - **offset**: index offset. * - **order**: specifies whether an ndarray is row-major (C-style) or column major (Fortran-style). * -* @param {ArrayLikeObject} arrays - array-like object containing input array, mask array and one output array +* @param {ArrayLikeObject} arrays - array-like object containing input array, mask array and output array * @throws {Error} input and mask arrays must have the same shape * @throws {Error} output array must have the one dimensional shape +* @throws {Error} input and output arrays must have the same data type * @returns {void} * * @example @@ -52,6 +78,7 @@ * // 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 mbuf = new Float64Array( [ 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 ] ); +* var ybuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * * // Define the shape of the input and mask arrays: * var shape = [ 3, 1, 2 ]; @@ -82,7 +109,7 @@ * }; * var out = { * 'dtype': 'float64', -* 'data': new Float64Array( 4 ), +* 'data': ybuf, * 'shape': [ 4 ], * 'strides': [ 1 ], * 'offset': 0, @@ -96,5 +123,58 @@ * // => [ 1.0, 5.0, 9.0, 11.0 ] */ function mskfilter( arrays ) { - -} \ No newline at end of file + var ndims; + var mask; + var shm; + var shx; + var x; + var y; + + // Unpack the ndarrays and standardize ndarray meta data: + x = ndarray2object( arrays[ 0 ] ); + mask = ndarray2object( arrays[ 1 ] ); + y = ndarray2object( arrays[ 2 ] ); + + // Verify that the input and mask arrays have the same number of dimensions... + shx = x.shape; + shm = mask.shape; + ndims = shx.length; + if ( ndims !== shm.length ) { + throw new Error( format( 'invalid arguments. Arrays must have the same number of dimensions (i.e., same rank). ndims(x) == %s. ndims(mask) == %s', ndims, shm.length ) ); + } + + // Verify that the input and mask arrays have the same shape... + for ( var i = 0; i < ndims; i++ ) { + if ( shx[ i ] !== shm[ i ] ) { + throw new Error( format( 'invalid arguments. Arrays must have the same shape. shape(x)[%s] == %s. shape(mask)[%s] == %s', i, shx[ i ], i, shm[ i ] ) ); + } + } + + // Verify that the output array has a one-dimensional shape... + if ( y.shape.length !== 1 ) { + throw new Error( 'invalid argument. Output array must have a one-dimensional shape. ndims(y) == %s', y.shape.length ); + } + + // Verify that the output array and input array have same data type... + if ( x.dtype !== y.dtype ) { + throw new Error( 'invalid arguments. Input and output arrays must have the same data type. dtype(x) == %s. dtype(y) == %s', x.dtype, y.dtype ); + } + + // Check whether we were provided an empty input ndarray... + if ( numel( shx ) === 0 ) { + return; + } + + // Determine whether we can avoid iteration altogether... + if ( ndims == 0 ) { + if ( x.accessorProtocol || mask.accessorProtocol || y.accessorProtocol ) { + return ACCESSOR_MSKFILTER[ ndims ]( x, mask, y ); + } + return MSKFILTER[ ndims ]( x, mask, y ); + } +} + + +// EXPORTS // + +module.exports = mskfilter; \ No newline at end of file From 2f0ba4ca5a318520cfedb10216349ba69fda43c7 Mon Sep 17 00:00:00 2001 From: Jaysukh-409 Date: Tue, 30 Jul 2024 16:43:44 +0530 Subject: [PATCH 03/34] feat: add kernels for 1d ndarray --- .../@stdlib/ndarray/base/mskfilter/README.md | 6 +- .../@stdlib/ndarray/base/mskfilter/lib/0d.js | 64 ++++- .../base/mskfilter/lib/0d_accessors.js | 88 ++++++- .../@stdlib/ndarray/base/mskfilter/lib/1d.js | 133 ++++++++++ .../base/mskfilter/lib/1d_accessors.js | 163 +++++++++++++ .../ndarray/base/mskfilter/lib/main.js | 227 +++++++++++++----- .../ndarray/base/mskfilter/package.json | 2 +- 7 files changed, 612 insertions(+), 71 deletions(-) create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d_accessors.js diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/README.md b/lib/node_modules/@stdlib/ndarray/base/mskfilter/README.md index 9cd04e83cd1..d349ac1bcbe 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/README.md +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/README.md @@ -20,7 +20,7 @@ limitations under the License. # mskfilter -> Apply a mask to a provided input ndarray and assigns to one-dimensional output ndarray. +> Apply a mask to a provided input ndarray and assign unmasked values to elements in a provided one-dimensional output ndarray.
@@ -36,9 +36,9 @@ limitations under the License. var mskfilter = require( '@stdlib/ndarray/base/mskfilter' ); ``` -#### assign ( arrays ) +#### mskfilter ( arrays ) -Apply a mask to a provided input ndarray and assigns to one-dimensional output ndarray. +Apply a mask to a provided input ndarray and assign unmasked values to elements in a provided one-dimensional output ndarray. ```javascript ``` diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/0d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/0d.js index 5c3056b3b1e..3f4ed15ad3e 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/0d.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/0d.js @@ -20,13 +20,69 @@ // MAIN // +/** +* Apply a mask to a provided input ndarray and assign unmasked values to elements in a provided one-dimensional output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {Object} mask - object containing mask ndarray meta data +* @param {Object} y - object containing output ndarray meta data +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Define the shape of the array: +* var shape = []; +* +* // Define the array strides: +* var sx = [ 0 ]; +* var sm = [ 0 ]; +* var sy = [ 0 ]; +* +* // Define the index offset: +* var ox = 0; +* var om = 0; +* +* var x = { +* 'dtype': 'float64', +* 'data': new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ), +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* var mask = { +* 'dtype': 'float64', +* 'data': new Float64Array( [ 1, 0, 1, 0, 1 ] ), +* 'shape': shape, +* 'strides': sm, +* 'offset': om, +* 'order': 'row-major' +* }; +* +* var y = { +* 'dtype': 'float64', +* 'data': new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ), +* 'shape': [ 5 ], +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major' +* }; +* +* mskfilter0d( x, mask, y ); +* +* console.log( y.data ); +* // => [ 1.0, 0.0, 0.0, 0.0, 0.0 ] +*/ function mskfilter0d( x, mask, y ) { - if ( mask.data[ mask.offset ] ) { - y.data[ y.offset ] = x.data[ x.offset ]; - } + if ( mask.data[ mask.offset ] ) { + y.data[ y.offset ] = x.data[ x.offset ]; + } } // EXPORTS // -module.exports = mskfilter0d; \ No newline at end of file +module.exports = mskfilter0d; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/0d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/0d_accessors.js index 56f6131f797..ed3d1298f26 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/0d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/0d_accessors.js @@ -20,13 +20,91 @@ // MAIN // -function accessor_mskfilter0d( x, mask, y ) { - if ( mask.accessor[ 0 ]( mask.data, mask.offset ) ) { - y.accessor[ 1 ]( y.data, y.offset, x.accessor[ 0 ]( x.data, x.offset ) ); - } +/** +* Apply a mask to a provided input ndarray and assign unmasked values to elements in a provided one-dimensional output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {Object} mask - object containing mask ndarray meta data +* @param {Object} y - object containing output ndarray meta data +* @returns {void} +* +* @example +* var BooleanArray = require( '@stdlib/array/bool' ); +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* var realf = require( '@stdlib/complex/realf' ); +* var imagf = require( '@stdlib/complex/imagf' ); +* +* // Define the shape of the array: +* var shape = []; +* +* // Define the array strides: +* var sx = [ 0 ]; +* var sm = [ 0 ]; +* var sy = [ 0 ]; +* +* // Define the index offset: +* var ox = 0; +* var om = 0; +* +* // Define getters and setters: +* function getter( buf, idx ) { +* return buf.get( idx ); +* } +* +* function setter( buf, idx, value ) { +* buf.set( value, idx ); +* } +* +* var x = { +* 'dtype': 'complex64', +* 'data': new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ), +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* var mask = { +* 'dtype': 'bool', +* 'data': new BooleanArray( [ 1, 0, 1, 0 ] ), +* 'shape': shape, +* 'strides': sm, +* 'offset': om, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* var y = { +* 'dtype': 'complex64', +* 'data': new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ), +* 'shape': [ 4 ], +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* mskfilter0d( x, mask, y ); +* +* var v = y.data.get( 0 ); +* // returns +* +* var re = realf( v ); +* // returns 1.0 +* +* var im = imagf( v ); +* // returns 2.0 +*/ +function mskfilter0d( x, mask, y ) { + if ( mask.accessors[ 0 ]( mask.data, mask.offset ) ) { + y.accessors[ 1 ]( y.data, y.offset, x.accessors[ 0 ]( x.data, x.offset ) ); + } } // EXPORTS // -module.exports = accessor_mskfilter0d; \ No newline at end of file +module.exports = mskfilter0d; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d.js new file mode 100644 index 00000000000..92921cebcdd --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d.js @@ -0,0 +1,133 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MAIN // + +/** +* Apply a mask to a provided input ndarray and assign unmasked values to elements in a provided one-dimensional output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {Object} mask - object containing mask ndarray meta data +* @param {Object} y - object containing output ndarray meta data +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Define the shape of the array: +* var shape = [ 5 ]; +* +* // Define the array strides: +* var sx = [ 2 ]; +* var sm = [ 1 ]; +* var sy = [ 1 ]; +* +* // Define the index offset: +* var ox = 1; +* var om = 0; +* +* var x = { +* 'dtype': 'float64', +* 'data': new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ), +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* var mask = { +* 'dtype': 'float64', +* 'data': new Float64Array( [ 1, 0, 1, 0, 1 ] ), +* 'shape': shape, +* 'strides': sm, +* 'offset': om, +* 'order': 'row-major' +* }; +* +* var y = { +* 'dtype': 'float64', +* 'data': new Float64Array( 4 ), +* 'shape': [ 4 ], +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major' +* }; +* +* mskfilter1d( x, mask, y ); +* +* console.log( y.data ); +* // => [ 2.0, 0.0, 0.0, 0.0 ] +*/ +function mskfilter1d( x, mask, y ) { + var xbuf; + var mbuf; + var ybuf; + var xlen; + var mlen; + var ylen; + var dx0; + var dm0; + var dy0; + var S0; + var ix; + var im; + var iy; + var i0; + + // Extract loop variables: dimensions and loop offset (pointer) increments... + S0 = x.shape[ 0 ]; + dx0 = x.strides[ 0 ]; + dm0 = mask.strides[ 0 ]; + dy0 = y.strides[ 0 ]; + + // Set the pointers to the first indexed elements in the respective ndarrays... + ix = x.offset; + im = mask.offset; + iy = y.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + mbuf = mask.data; + ybuf = y.data; + + // Extract the array lengths... + xlen = xbuf.length; + mlen = mbuf.length; + ylen = ybuf.length; + + // Iterate over the ndarray dimensions... + for ( i0 = 0; i0 < S0; i0++ ) { + if ( ix >= xlen || im >= mlen || iy >= ylen ) { + return; + } + if ( mbuf[ im ] ) { + ybuf[ iy ] = xbuf[ ix ]; + } + ix += dx0; + iy += dy0; + im += dm0; + } +} + + +// EXPORTS // + +module.exports = mskfilter1d; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d_accessors.js new file mode 100644 index 00000000000..0c90546f7d2 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d_accessors.js @@ -0,0 +1,163 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MAIN // + +/** +* Apply a mask to a provided input ndarray and assign unmasked values to elements in a provided one-dimensional output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {Object} mask - object containing mask ndarray meta data +* @param {Object} y - object containing output ndarray meta data +* @returns {void} +* +* @example +* var BooleanArray = require( '@stdlib/array/bool' ); +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* var realf = require( '@stdlib/complex/realf' ); +* var imagf = require( '@stdlib/complex/imagf' ); +* +* // Define the shape of the array: +* var shape = [ 3 ]; +* +* // Define the array strides: +* var sx = [ 1 ]; +* var sm = [ 1 ]; +* var sy = [ 1 ]; +* +* // Define the index offset: +* var ox = 1; +* var om = 0; +* +* // Define getters and setters: +* function getter( buf, idx ) { +* return buf.get( idx ); +* } +* +* function setter( buf, idx, value ) { +* buf.set( value, idx ); +* } +* +* var x = { +* 'dtype': 'complex64', +* 'data': new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ), +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* var mask = { +* 'dtype': 'bool', +* 'data': new BooleanArray( [ 1, 0, 1 ] ), +* 'shape': shape, +* 'strides': sm, +* 'offset': om, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* var y = { +* 'dtype': 'complex64', +* 'data': new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ), +* 'shape': [ 2 ], +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* mskfilter1d( x, mask, y ); +* +* var v = y.data.get( 0 ); +* // returns +* +* var re = realf( v ); +* // returns 3.0 +* +* var im = imagf( v ); +* // returns 4.0 +*/ +function mskfilter1d( x, mask, y ) { + var xbuf; + var mbuf; + var ybuf; + var xlen; + var mlen; + var ylen; + var getm; + var getx; + var sety; + var dx0; + var dm0; + var dy0; + var S0; + var ix; + var im; + var iy; + var i0; + + // Extract loop variables: dimensions and loop offset (pointer) increments... + S0 = x.shape[ 0 ]; + dx0 = x.strides[ 0 ]; + dm0 = mask.strides[ 0 ]; + dy0 = y.strides[ 0 ]; + + // Set the pointers to the first indexed elements in the respective ndarrays... + ix = x.offset; + im = mask.offset; + iy = y.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + mbuf = mask.data; + ybuf = y.data; + + // Extract the array lengths... + xlen = xbuf.length; + mlen = mbuf.length; + ylen = ybuf.length; + + // Cache accessors: + getx = x.accessors[ 0 ]; + getm = mask.accessors[ 0 ]; + sety = y.accessors[ 1 ]; + + // Iterate over the ndarray dimensions... + for ( i0 = 0; i0 < S0; i0++ ) { + if ( ix >= xlen || im >= mlen || iy >= ylen ) { + return; + } + if ( getm( mbuf, im ) ) { + sety( ybuf, iy, getx( xbuf, ix ) ); + } + ix += dx0; + im += dm0; + iy += dy0; + } +} + + +// EXPORTS // + +module.exports = mskfilter1d; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js index 5267197d11c..3b3ec648492 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js @@ -20,26 +20,31 @@ // MODULES // - +var iterationOrder = require( '@stdlib/ndarray/base/iteration-order' ); var ndarray2object = require( '@stdlib/ndarray/base/ndarraylike2object' ); +var minmaxViewBufferIndex = require( '@stdlib/ndarray/base/minmax-view-buffer-index' ); var format = require( '@stdlib/string/format' ); var numel = require( '@stdlib/ndarray/base/numel' ); -var accessor_mskfilter0d = require( './0d_accessors.js' ); +var accessorMskfilter0d = require( './0d_accessors.js' ); +var accessorMskfilter1d = require( './1d_accessors.js' ); var mskfilter0d = require( './0d.js' ); +var mskfilter1d = require( './1d.js' ); -// VARIABLES // +// VARIABLES // var MSKFILTER = [ - mskfilter0d, + mskfilter0d, + mskfilter1d ]; var ACCESSOR_MSKFILTER = [ - accessor_mskfilter0d, + accessorMskfilter0d, + accessorMskfilter1d ]; -var BLOCKED_MSKFILTER = [ - +var BLOCKED_MSKFILTER = [ + ]; var BLOCKED_ACCESSOR_MSKFILTER = [ @@ -52,7 +57,7 @@ var MAX_DIMS = MSKFILTER.length - 1; // MAIN // /** -* Apply a mask to a provided input ndarray and assigns to one-dimensional output ndarray. +* Apply a mask to a provided input ndarray and assign unmasked values to elements in a provided one-dimensional output ndarray. * * ## Notes * @@ -123,58 +128,164 @@ var MAX_DIMS = MSKFILTER.length - 1; * // => [ 1.0, 5.0, 9.0, 11.0 ] */ function mskfilter( arrays ) { - var ndims; - var mask; - var shm; - var shx; - var x; - var y; - - // Unpack the ndarrays and standardize ndarray meta data: - x = ndarray2object( arrays[ 0 ] ); - mask = ndarray2object( arrays[ 1 ] ); - y = ndarray2object( arrays[ 2 ] ); - - // Verify that the input and mask arrays have the same number of dimensions... - shx = x.shape; - shm = mask.shape; - ndims = shx.length; - if ( ndims !== shm.length ) { - throw new Error( format( 'invalid arguments. Arrays must have the same number of dimensions (i.e., same rank). ndims(x) == %s. ndims(mask) == %s', ndims, shm.length ) ); - } - - // Verify that the input and mask arrays have the same shape... - for ( var i = 0; i < ndims; i++ ) { - if ( shx[ i ] !== shm[ i ] ) { - throw new Error( format( 'invalid arguments. Arrays must have the same shape. shape(x)[%s] == %s. shape(mask)[%s] == %s', i, shx[ i ], i, shm[ i ] ) ); - } - } - - // Verify that the output array has a one-dimensional shape... - if ( y.shape.length !== 1 ) { - throw new Error( 'invalid argument. Output array must have a one-dimensional shape. ndims(y) == %s', y.shape.length ); - } - - // Verify that the output array and input array have same data type... - if ( x.dtype !== y.dtype ) { - throw new Error( 'invalid arguments. Input and output arrays must have the same data type. dtype(x) == %s. dtype(y) == %s', x.dtype, y.dtype ); - } - - // Check whether we were provided an empty input ndarray... - if ( numel( shx ) === 0 ) { - return; - } - - // Determine whether we can avoid iteration altogether... - if ( ndims == 0 ) { - if ( x.accessorProtocol || mask.accessorProtocol || y.accessorProtocol ) { - return ACCESSOR_MSKFILTER[ ndims ]( x, mask, y ); - } - return MSKFILTER[ ndims ]( x, mask, y ); - } + var ndims; + var xmmv; + var mmmv; + var mask; + var shm; + var shx; + var iox; + var iom; + var len; + var ox; + var om; + var sx; + var sm; + var ns; + var d; + var x; + var y; + var i; + + // Unpack the ndarrays and standardize ndarray meta data: + x = ndarray2object( arrays[ 0 ] ); + mask = ndarray2object( arrays[ 1 ] ); + y = ndarray2object( arrays[ 2 ] ); + + // Verify that the input and mask arrays have the same number of dimensions... + shx = x.shape; + shm = mask.shape; + ndims = shx.length; + if ( ndims !== shm.length ) { + throw new Error( format( 'invalid arguments. Arrays must have the same number of dimensions (i.e., same rank). ndims(x) == %s. ndims(mask) == %s', ndims, shm.length ) ); + } + + // Verify that the input and mask arrays have the same shape... + ns = 0; + for ( i = 0; i < ndims; i++ ) { + d = shx[i]; + if ( d !== shm[ i ] ) { + throw new Error( format( 'invalid arguments. Arrays must have the same shape. shape(x)[%s] == %s. shape(mask)[%s] == %s', i, d, i, shm[ i ] ) ); + } + // Check whether the current dimension is a singleton dimension... + if ( d === 1 ) { + ns += 1; + } + } + + // Verify that the output array has a one-dimensional shape... + if ( y.shape.length !== 1 ) { + throw new Error( 'invalid argument. Output array must have a one-dimensional shape. ndims(y) == %s', y.shape.length ); + } + + // Verify that the output array and input array have same data type... + if ( x.dtype !== y.dtype ) { + throw new Error( 'invalid arguments. Input and output arrays must have the same data type. dtype(x) == %s. dtype(y) == %s', x.dtype, y.dtype ); + } + + // Check whether we were provided an empty input ndarray... + len = numel( shx ); + if ( len === 0 ) { + return; + } + + // Determine whether we can avoid iteration altogether... + if ( ndims === 0 ) { + if ( x.accessorProtocol || mask.accessorProtocol || y.accessorProtocol ) { + return ACCESSOR_MSKFILTER[ ndims ]( x, mask, y ); + } + return MSKFILTER[ ndims ]( x, mask, y ); + } + + // Determine whether the ndarrays are one-dimensional and thus readily translate to one-dimensional strided arrays... + if ( ndims === 1 ) { + if ( x.accessorProtocol || mask.accessorProtocol || y.accessorProtocol ) { + return ACCESSOR_MSKFILTER[ ndims ]( x, mask, y ); + } + return MSKFILTER[ ndims ]( x, mask, y ); + } + sx = x.strides; + sm = mask.strides; + + // Determine whether the ndarray has only **one** non-singleton dimension (e.g., ndims=4, shape=[10,1,1,1]) so that we can treat the ndarrays as being equivalent to one-dimensional strided arrays... + if ( ns === ndims-1 ) { + // Get the index of the non-singleton dimension... + for ( i = 0; i < ndims; i++ ) { + if ( shx[ i ] !== 1 ) { + break; + } + } + x.shape = [ shx[i] ]; + mask.shape = x.shape; + x.strides = [ sx[i] ]; + mask.strides = [ sm[i] ]; + if ( x.accessorProtocol || mask.accessorProtocol || y.accessorProtocol ) { + return ACCESSOR_MSKFILTER[ 1 ]( x, mask, y ); + } + return MSKFILTER[ 1 ]( x, mask, y ); + } + iox = iterationOrder( sx ); // +/-1 + iom = iterationOrder( sm ); // +/-1 + + // Determine whether we can avoid blocked iteration... + if ( iox !== 0 && iom !== 0 && x.order === mask.order ) { + // Determine the minimum and maximum linear indices which are accessible by the array views: + xmmv = minmaxViewBufferIndex( shx, sx, x.offset ); + mmmv = minmaxViewBufferIndex( shm, sm, mask.offset ); + + // Determine whether we can ignore shape (and strides) and treat the ndarrays as linear one-dimensional strided arrays... + if ( len === ( xmmv[1]-xmmv[0]+1 ) && len === ( mmmv[1]-mmmv[0]+1 ) ) { + // Note: the above is equivalent to @stdlib/ndarray/base/assert/is-contiguous, but in-lined so we can retain computed values... + if ( iox === 1 ) { + ox = xmmv[ 0 ]; + } else { + ox = xmmv[ 1 ]; + } + if ( iom === 1 ) { + om = mmmv[ 0 ]; + } else { + om = mmmv[ 1 ]; + } + x.shape = [ len ]; + mask.shape = x.shape; + x.strides = [ iox ]; + mask.strides = [ iom ]; + x.offset = ox; + mask.offset = om; + if ( x.accessorProtocol || mask.accessorProtocol || y.accessorProtocol ) { + return ACCESSOR_MSKFILTER[ 1 ]( x, mask, y ); + } + return MSKFILTER[ 1 ]( x, mask, y ); + } + // At least one ndarray is non-contiguous, so we cannot directly use one-dimensional array functionality... + + // Determine whether we can use simple nested loops... + if ( ndims <= MAX_DIMS ) { + // So long as iteration for each respective array always moves in the same direction (i.e., no mixed sign strides), we can leverage cache-optimal (i.e., normal) nested loops without resorting to blocked iteration... + if ( x.accessorProtocol || mask.accessorProtocol || y.accessorProtocol ) { + return ACCESSOR_MSKFILTER[ ndims ]( x, mask, y ); + } + return MSKFILTER[ ndims ]( x, mask, y ); + } + // Fall-through to blocked iteration... + } + // At this point, we're either dealing with non-contiguous n-dimensional arrays, high dimensional n-dimensional arrays, and/or arrays having differing memory layouts, so our only hope is that we can still perform blocked iteration... + + // Determine whether we can perform blocked iteration... + if ( ndims <= MAX_DIMS ) { + if ( x.accessorProtocol || mask.accessorProtocol || y.accessorProtocol ) { + return BLOCKED_ACCESSOR_MSKFILTER[ ndims-2 ]( x, mask, y ); + } + return BLOCKED_MSKFILTER[ ndims-2 ]( x, mask, y ); + } + // Fall-through to linear view iteration without regard for how data is stored in memory (i.e., take the slow path)... + if ( x.accessorProtocol || mask.accessorProtocol || y.accessorProtocol ) { + return accessorassignnd( x, mask, y ); + } + assignnd( x, mask, y ); } // EXPORTS // -module.exports = mskfilter; \ No newline at end of file +module.exports = mskfilter; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/package.json b/lib/node_modules/@stdlib/ndarray/base/mskfilter/package.json index d039c1cfa33..64b8e552732 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/package.json +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/ndarray/base/mskfilter", "version": "0.0.0", - "description": "Apply a mask to a provided input ndarray and assigns to one-dimensional output ndarray.", + "description": "Apply a mask to a provided input ndarray and assign unmasked values to elements in a provided one-dimensional output ndarray.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", From d5bcb070be5897ba2789699936295326fa775c65 Mon Sep 17 00:00:00 2001 From: Jaysukh-409 Date: Thu, 1 Aug 2024 14:11:37 +0530 Subject: [PATCH 04/34] refactor: update the implementation for 1d kernels --- .../@stdlib/ndarray/base/mskfilter/lib/1d.js | 21 +++++-------------- .../base/mskfilter/lib/1d_accessors.js | 19 ++++------------- 2 files changed, 9 insertions(+), 31 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d.js index 92921cebcdd..00ede80f52c 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d.js @@ -46,7 +46,7 @@ * * var x = { * 'dtype': 'float64', -* 'data': new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ), +* 'data': new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0 ] ), * 'shape': shape, * 'strides': sx, * 'offset': ox, @@ -64,8 +64,8 @@ * * var y = { * 'dtype': 'float64', -* 'data': new Float64Array( 4 ), -* 'shape': [ 4 ], +* 'data': new Float64Array( 3 ), +* 'shape': [ 3 ], * 'strides': sy, * 'offset': 0, * 'order': 'row-major' @@ -74,15 +74,12 @@ * mskfilter1d( x, mask, y ); * * console.log( y.data ); -* // => [ 2.0, 0.0, 0.0, 0.0 ] +* // => [ 2.0, 6.0, 10.0 ] */ function mskfilter1d( x, mask, y ) { var xbuf; var mbuf; var ybuf; - var xlen; - var mlen; - var ylen; var dx0; var dm0; var dy0; @@ -108,21 +105,13 @@ function mskfilter1d( x, mask, y ) { mbuf = mask.data; ybuf = y.data; - // Extract the array lengths... - xlen = xbuf.length; - mlen = mbuf.length; - ylen = ybuf.length; - // Iterate over the ndarray dimensions... for ( i0 = 0; i0 < S0; i0++ ) { - if ( ix >= xlen || im >= mlen || iy >= ylen ) { - return; - } if ( mbuf[ im ] ) { ybuf[ iy ] = xbuf[ ix ]; + iy += dy0; } ix += dx0; - iy += dy0; im += dm0; } } diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d_accessors.js index 0c90546f7d2..6253b4e751c 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d_accessors.js @@ -45,7 +45,7 @@ * var sy = [ 1 ]; * * // Define the index offset: -* var ox = 1; +* var ox = 0; * var om = 0; * * // Define getters and setters: @@ -93,18 +93,15 @@ * // returns * * var re = realf( v ); -* // returns 3.0 +* // returns 1.0 * * var im = imagf( v ); -* // returns 4.0 +* // returns 2.0 */ function mskfilter1d( x, mask, y ) { var xbuf; var mbuf; var ybuf; - var xlen; - var mlen; - var ylen; var getm; var getx; var sety; @@ -133,11 +130,6 @@ function mskfilter1d( x, mask, y ) { mbuf = mask.data; ybuf = y.data; - // Extract the array lengths... - xlen = xbuf.length; - mlen = mbuf.length; - ylen = ybuf.length; - // Cache accessors: getx = x.accessors[ 0 ]; getm = mask.accessors[ 0 ]; @@ -145,15 +137,12 @@ function mskfilter1d( x, mask, y ) { // Iterate over the ndarray dimensions... for ( i0 = 0; i0 < S0; i0++ ) { - if ( ix >= xlen || im >= mlen || iy >= ylen ) { - return; - } if ( getm( mbuf, im ) ) { sety( ybuf, iy, getx( xbuf, ix ) ); + iy += dy0; } ix += dx0; im += dm0; - iy += dy0; } } From 5010468c8730d2a1738871f835542c9bf17e66f3 Mon Sep 17 00:00:00 2001 From: Jaysukh-409 Date: Thu, 1 Aug 2024 14:46:36 +0530 Subject: [PATCH 05/34] feat: add kernels for 2d ndarray --- .../@stdlib/ndarray/base/mskfilter/lib/2d.js | 150 ++++++++++++ .../base/mskfilter/lib/2d_accessors.js | 180 +++++++++++++++ .../ndarray/base/mskfilter/lib/2d_blocked.js | 185 +++++++++++++++ .../mskfilter/lib/2d_blocked_accessors.js | 215 ++++++++++++++++++ 4 files changed, 730 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked_accessors.js diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d.js new file mode 100644 index 00000000000..50850014c53 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d.js @@ -0,0 +1,150 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MAIN // + +/** +* Apply a mask to a provided input ndarray and assign unmasked values to elements in a provided one-dimensional output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {Object} mask - object containing mask ndarray meta data +* @param {Object} y - object containing output ndarray meta data +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Define the shape of the array: +* var shape = [ 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 4, 1 ]; +* var sm = [ 2, 1 ]; +* var sy = [ 1 ]; +* +* // Define the index offset: +* var ox = 0; +* var om = 0; +* +* var x = { +* 'dtype': 'float64', +* 'data': new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ), +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* var mask = { +* 'dtype': 'float64', +* 'data': new Float64Array( [ 1, 0, 1, 0 ] ), +* 'shape': shape, +* 'strides': sm, +* 'offset': om, +* 'order': 'row-major' +* }; +* +* var y = { +* 'dtype': 'float64', +* 'data': new Float64Array( 2 ), +* 'shape': [ 2 ], +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major' +* }; +* +* mskfilter2d( x, mask, y ); +* +* console.log( y.data ); +* // => [ 1.0, 5.0 ] +*/ +function mskfilter2d( x, mask, y ) { + var xbuf; + var mbuf; + var ybuf; + var dx0; + var dx1; + var dm0; + var dm1; + var dy0; + var S0; + var S1; + var sh; + var sm; + var sx; + var ix; + var im; + var iy; + var i0; + var i1; + + // Extract loop variables: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + sm = mask.strides; + if ( x.order === 'row-major' ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 1 ]; + S1 = sh[ 0 ]; + dx0 = sx[ 1 ]; // offset increment for innermost loop + dx1 = sx[ 0 ] - ( S0*sx[1] ); // offset increment for outermost loop + dm0 = sm[ 1 ]; + dm1 = sm[ 0 ] - ( S0*sm[1] ); + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); // offset increment for outermost loop + dm0 = sm[ 0 ]; + dm1 = sm[ 1 ] - ( S0*sm[0] ); + } + dy0 = y.strides[ 0 ]; + + // Set the pointers to the first indexed elements in the respective ndarrays... + ix = x.offset; + im = mask.offset; + iy = y.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + mbuf = mask.data; + ybuf = y.data; + + // Iterate over the ndarray dimensions... + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( mbuf[ im ] ) { + ybuf[ iy ] = xbuf[ ix ]; + iy += dy0; + } + ix += dx0; + im += dm0; + } + ix += dx1; + im += dm1; + } +} + + +// EXPORTS // + +module.exports = mskfilter2d; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_accessors.js new file mode 100644 index 00000000000..ad1851664f6 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_accessors.js @@ -0,0 +1,180 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MAIN // + +/** +* Apply a mask to a provided input ndarray and assign unmasked values to elements in a provided one-dimensional output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {Object} mask - object containing mask ndarray meta data +* @param {Object} y - object containing output ndarray meta data +* @returns {void} +* +* @example +* var BooleanArray = require( '@stdlib/array/bool' ); +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* var realf = require( '@stdlib/complex/realf' ); +* var imagf = require( '@stdlib/complex/imagf' ); +* +* // Define the shape of the array: +* var shape = [ 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 2, 1 ]; +* var sm = [ 2, 1 ]; +* var sy = [ 1 ]; +* +* // Define the index offset: +* var ox = 0; +* var om = 0; +* +* // Define getters and setters: +* function getter( buf, idx ) { +* return buf.get( idx ); +* } +* +* function setter( buf, idx, value ) { +* buf.set( value, idx ); +* } +* +* var x = { +* 'dtype': 'complex64', +* 'data': new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ), +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* var mask = { +* 'dtype': 'bool', +* 'data': new BooleanArray( [ 1, 0, 1, 0 ] ), +* 'shape': shape, +* 'strides': sm, +* 'offset': om, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* var y = { +* 'dtype': 'complex64', +* 'data': new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ), +* 'shape': [ 2 ], +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* mskfilter2d( x, mask, y ); +* +* var v = y.data.get( 0 ); +* // returns +* +* var re = realf( v ); +* // returns 1.0 +* +* var im = imagf( v ); +* // returns 2.0 +*/ +function mskfilter2d( x, mask, y ) { + var xbuf; + var mbuf; + var ybuf; + var getx; + var getm; + var sety; + var dx0; + var dx1; + var dm0; + var dm1; + var dy0; + var S0; + var S1; + var sh; + var sm; + var sx; + var ix; + var im; + var iy; + var i0; + var i1; + + // Extract loop variables: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + sm = mask.strides; + if ( x.order === 'row-major' ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 1 ]; + S1 = sh[ 0 ]; + dx0 = sx[ 1 ]; // offset increment for innermost loop + dx1 = sx[ 0 ] - ( S0*sx[1] ); // offset increment for outermost loop + dm0 = sm[ 1 ]; + dm1 = sm[ 0 ] - ( S0*sm[1] ); + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); // offset increment for outermost loop + dm0 = sm[ 0 ]; + dm1 = sm[ 1 ] - ( S0*sm[0] ); + } + dy0 = y.strides[ 0 ]; + + // Set the pointers to the first indexed elements in the respective ndarrays... + ix = x.offset; + im = mask.offset; + iy = y.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + mbuf = mask.data; + ybuf = y.data; + + // Cache accessors: + getx = x.accessors[ 0 ]; + getm = mask.accessors[ 0 ]; + sety = y.accessors[ 1 ]; + + // Iterate over the ndarray dimensions... + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( getm( mbuf, im ) ) { + sety( ybuf, iy, getx( xbuf, ix ) ); + iy += dy0; + } + ix += dx0; + im += dm0; + } + ix += dx1; + im += dm1; + } +} + + +// EXPORTS // + +module.exports = mskfilter2d; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked.js new file mode 100644 index 00000000000..745650d9123 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked.js @@ -0,0 +1,185 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/unary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); + + +// MAIN // + +/** +* Apply a mask to a provided input ndarray and assign unmasked values to elements in a provided one-dimensional output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {Object} mask - object containing mask ndarray meta data +* @param {Object} y - object containing output ndarray meta data +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Define the shape of the array: +* var shape = [ 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 4, 1 ]; +* var sm = [ 2, 1 ]; +* var sy = [ 1 ]; +* +* // Define the index offset: +* var ox = 0; +* var om = 0; +* +* var x = { +* 'dtype': 'float64', +* 'data': new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ), +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* var mask = { +* 'dtype': 'float64', +* 'data': new Float64Array( [ 1, 0, 1, 0 ] ), +* 'shape': shape, +* 'strides': sm, +* 'offset': om, +* 'order': 'row-major' +* }; +* +* var y = { +* 'dtype': 'float64', +* 'data': new Float64Array( 2 ), +* 'shape': [ 2 ], +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major' +* }; +* +* blockedmskfilter2d( x, mask, y ); +* +* console.log( y.data ); +* // => [ 1.0, 5.0 ] +*/ +function blockedmskfilter2d( x, mask, y ) { + var bsize; + var xbuf; + var mbuf; + var ybuf; + var dx0; + var dx1; + var dm0; + var dm1; + var dy0; + var ox1; + var om1; + var sh; + var s0; + var s1; + var sx; + var sm; + var ox; + var om; + var ix; + var im; + var iy; + var i0; + var i1; + var j0; + var j1; + var o; + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides, mask.strides ); + sh = o.sh; + sx = o.sx; + sm = o.sy; + + // Determine the block size: + bsize = blockSize( x.dtype, mask.dtype ); + + // Cache the indices of the first indexed elements in the respective ndarrays... + ox = x.offset; + om = mask.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + mbuf = mask.data; + ybuf = y.data; + + // Cache offset increments for the innermost loop... + dx0 = sx[0]; + dm0 = sm[0]; + dy0 = y.strides[0]; + + iy = y.offset; + + // Iterate over blocks... + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + ox1 = ox + ( j1*sx[1] ); + om1 = om + ( j1*sm[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute index offsets for the first input and output ndarray elements in the current block... + ix = ox1 + ( j0*sx[0] ); + im = om1 + ( j0*sm[0] ); + + // Compute loop offset increments... + dx1 = sx[1] - ( s0*sx[0] ); + dm1 = sm[1] - ( s0*sm[0] ); + + // Iterate over the ndarray dimensions... + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( mbuf[ im ] ) { + ybuf[ iy ] = xbuf[ ix ]; + iy += dy0; + } + ix += dx0; + im += dm0; + } + ix += dx1; + im += dm1; + } + } + } +} + + +// EXPORTS // + +module.exports = blockedmskfilter2d; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked_accessors.js new file mode 100644 index 00000000000..df97f93151f --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked_accessors.js @@ -0,0 +1,215 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/unary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); + + +// MAIN // + +/** +* Apply a mask to a provided input ndarray and assign unmasked values to elements in a provided one-dimensional output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {Object} mask - object containing mask ndarray meta data +* @param {Object} y - object containing output ndarray meta data +* @returns {void} +* +* @example +* var BooleanArray = require( '@stdlib/array/bool' ); +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* var realf = require( '@stdlib/complex/realf' ); +* var imagf = require( '@stdlib/complex/imagf' ); +* +* // Define the shape of the array: +* var shape = [ 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 2, 1 ]; +* var sm = [ 2, 1 ]; +* var sy = [ 1 ]; +* +* // Define the index offset: +* var ox = 0; +* var om = 0; +* +* // Define getters and setters: +* function getter( buf, idx ) { +* return buf.get( idx ); +* } +* +* function setter( buf, idx, value ) { +* buf.set( value, idx ); +* } +* +* var x = { +* 'dtype': 'complex64', +* 'data': new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ), +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* var mask = { +* 'dtype': 'bool', +* 'data': new BooleanArray( [ 1, 0, 1, 0 ] ), +* 'shape': shape, +* 'strides': sm, +* 'offset': om, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* var y = { +* 'dtype': 'complex64', +* 'data': new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ), +* 'shape': [ 2 ], +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* blockedmskfilter2d( x, mask, y ); +* +* var v = y.data.get( 0 ); +* // returns +* +* var re = realf( v ); +* // returns 1.0 +* +* var im = imagf( v ); +* // returns 2.0 +*/ +function blockedmskfilter2d( x, mask, y ) { + var bsize; + var xbuf; + var mbuf; + var ybuf; + var getx; + var getm; + var sety; + var dx0; + var dx1; + var dm0; + var dm1; + var dy0; + var ox1; + var om1; + var sh; + var s0; + var s1; + var sx; + var sm; + var ox; + var om; + var ix; + var im; + var iy; + var i0; + var i1; + var j0; + var j1; + var o; + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides, mask.strides ); + sh = o.sh; + sx = o.sx; + sm = o.sy; + + // Determine the block size: + bsize = blockSize( x.dtype, mask.dtype ); + + // Cache the indices of the first indexed elements in the respective ndarrays... + ox = x.offset; + om = mask.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + mbuf = mask.data; + ybuf = y.data; + + // Cache offset increments for the innermost loop... + dx0 = sx[0]; + dm0 = sm[0]; + dy0 = y.strides[0]; + + iy = y.offset; + + // Cache accessors: + getx = x.accessors[ 0 ]; + getm = mask.accessors[ 0 ]; + sety = y.accessors[ 1 ]; + + // Iterate over blocks... + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + ox1 = ox + ( j1*sx[1] ); + om1 = om + ( j1*sm[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute index offsets for the first input and output ndarray elements in the current block... + ix = ox1 + ( j0*sx[0] ); + im = om1 + ( j0*sm[0] ); + + // Compute loop offset increments... + dx1 = sx[1] - ( s0*sx[0] ); + dm1 = sm[1] - ( s0*sm[0] ); + + // Iterate over the ndarray dimensions... + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( getm( mbuf, im ) ) { + sety( ybuf, iy, getx( xbuf, ix ) ); + iy += dy0; + } + ix += dx0; + im += dm0; + } + ix += dx1; + im += dm1; + } + } + } +} + + +// EXPORTS // + +module.exports = blockedmskfilter2d; From 6f3992f70e0531d3288a4a1c746494b1c52f0a71 Mon Sep 17 00:00:00 2001 From: Jaysukh-409 Date: Fri, 2 Aug 2024 12:20:16 +0530 Subject: [PATCH 06/34] docs: update description of loop kernel --- lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/0d.js | 2 +- .../@stdlib/ndarray/base/mskfilter/lib/0d_accessors.js | 2 +- lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d.js | 2 +- .../@stdlib/ndarray/base/mskfilter/lib/1d_accessors.js | 2 +- lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d.js | 2 +- .../@stdlib/ndarray/base/mskfilter/lib/2d_accessors.js | 2 +- .../@stdlib/ndarray/base/mskfilter/lib/2d_blocked.js | 2 +- .../@stdlib/ndarray/base/mskfilter/lib/2d_blocked_accessors.js | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/0d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/0d.js index 3f4ed15ad3e..fdbe0685da9 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/0d.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/0d.js @@ -21,7 +21,7 @@ // MAIN // /** -* Apply a mask to a provided input ndarray and assign unmasked values to elements in a provided one-dimensional output ndarray. +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. * * @private * @param {Object} x - object containing input ndarray meta data diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/0d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/0d_accessors.js index ed3d1298f26..4e1fb1473b5 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/0d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/0d_accessors.js @@ -21,7 +21,7 @@ // MAIN // /** -* Apply a mask to a provided input ndarray and assign unmasked values to elements in a provided one-dimensional output ndarray. +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. * * @private * @param {Object} x - object containing input ndarray meta data diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d.js index 00ede80f52c..ebc61e7861d 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d.js @@ -21,7 +21,7 @@ // MAIN // /** -* Apply a mask to a provided input ndarray and assign unmasked values to elements in a provided one-dimensional output ndarray. +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. * * @private * @param {Object} x - object containing input ndarray meta data diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d_accessors.js index 6253b4e751c..37332071459 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d_accessors.js @@ -21,7 +21,7 @@ // MAIN // /** -* Apply a mask to a provided input ndarray and assign unmasked values to elements in a provided one-dimensional output ndarray. +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. * * @private * @param {Object} x - object containing input ndarray meta data diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d.js index 50850014c53..54d652a5f0a 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d.js @@ -21,7 +21,7 @@ // MAIN // /** -* Apply a mask to a provided input ndarray and assign unmasked values to elements in a provided one-dimensional output ndarray. +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. * * @private * @param {Object} x - object containing input ndarray meta data diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_accessors.js index ad1851664f6..bab42438555 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_accessors.js @@ -21,7 +21,7 @@ // MAIN // /** -* Apply a mask to a provided input ndarray and assign unmasked values to elements in a provided one-dimensional output ndarray. +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. * * @private * @param {Object} x - object containing input ndarray meta data diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked.js index 745650d9123..71820210c17 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked.js @@ -27,7 +27,7 @@ var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); // MAIN // /** -* Apply a mask to a provided input ndarray and assign unmasked values to elements in a provided one-dimensional output ndarray. +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. * * @private * @param {Object} x - object containing input ndarray meta data diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked_accessors.js index df97f93151f..9984bf7fbb6 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked_accessors.js @@ -27,7 +27,7 @@ var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); // MAIN // /** -* Apply a mask to a provided input ndarray and assign unmasked values to elements in a provided one-dimensional output ndarray. +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. * * @private * @param {Object} x - object containing input ndarray meta data From ecffc5519520363aa050024edee22a96e4e07a98 Mon Sep 17 00:00:00 2001 From: Jaysukh-409 Date: Fri, 2 Aug 2024 12:31:35 +0530 Subject: [PATCH 07/34] docs: refactor JSDoc example for loop kernels --- .../@stdlib/ndarray/base/mskfilter/lib/0d.js | 11 ++++++----- .../ndarray/base/mskfilter/lib/0d_accessors.js | 4 ++-- .../@stdlib/ndarray/base/mskfilter/lib/1d.js | 5 +++-- .../ndarray/base/mskfilter/lib/1d_accessors.js | 2 +- .../@stdlib/ndarray/base/mskfilter/lib/2d.js | 5 +++-- .../ndarray/base/mskfilter/lib/2d_accessors.js | 2 +- .../@stdlib/ndarray/base/mskfilter/lib/2d_blocked.js | 5 +++-- .../base/mskfilter/lib/2d_blocked_accessors.js | 2 +- 8 files changed, 20 insertions(+), 16 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/0d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/0d.js index fdbe0685da9..15ed6c91389 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/0d.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/0d.js @@ -31,6 +31,7 @@ * * @example * var Float64Array = require( '@stdlib/array/float64' ); +* var Uint8Array = require( '@stdlib/array/uint8' ); * * // Define the shape of the array: * var shape = []; @@ -54,8 +55,8 @@ * }; * * var mask = { -* 'dtype': 'float64', -* 'data': new Float64Array( [ 1, 0, 1, 0, 1 ] ), +* 'dtype': 'uint8', +* 'data': new Uint8Array( [ 1, 0, 1, 0, 1 ] ), * 'shape': shape, * 'strides': sm, * 'offset': om, @@ -64,8 +65,8 @@ * * var y = { * 'dtype': 'float64', -* 'data': new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ), -* 'shape': [ 5 ], +* 'data': new Float64Array( 3 ), +* 'shape': [ 3 ], * 'strides': sy, * 'offset': 0, * 'order': 'row-major' @@ -74,7 +75,7 @@ * mskfilter0d( x, mask, y ); * * console.log( y.data ); -* // => [ 1.0, 0.0, 0.0, 0.0, 0.0 ] +* // => [ 1.0, 0.0, 0.0 ] */ function mskfilter0d( x, mask, y ) { if ( mask.data[ mask.offset ] ) { diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/0d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/0d_accessors.js index 4e1fb1473b5..0c068e55346 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/0d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/0d_accessors.js @@ -79,8 +79,8 @@ * * var y = { * 'dtype': 'complex64', -* 'data': new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ), -* 'shape': [ 4 ], +* 'data': new Complex64Array( 2 ), +* 'shape': [ 2 ], * 'strides': sy, * 'offset': 0, * 'order': 'row-major', diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d.js index ebc61e7861d..123a29869ab 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d.js @@ -31,6 +31,7 @@ * * @example * var Float64Array = require( '@stdlib/array/float64' ); +* var Uint8Array = require( '@stdlib/array/uint8' ); * * // Define the shape of the array: * var shape = [ 5 ]; @@ -54,8 +55,8 @@ * }; * * var mask = { -* 'dtype': 'float64', -* 'data': new Float64Array( [ 1, 0, 1, 0, 1 ] ), +* 'dtype': 'uint8', +* 'data': new Uint8Array( [ 1, 0, 1, 0, 1 ] ), * 'shape': shape, * 'strides': sm, * 'offset': om, diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d_accessors.js index 37332071459..63cc6e77a7b 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d_accessors.js @@ -79,7 +79,7 @@ * * var y = { * 'dtype': 'complex64', -* 'data': new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ), +* 'data': new Complex64Array( 2 ), * 'shape': [ 2 ], * 'strides': sy, * 'offset': 0, diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d.js index 54d652a5f0a..80687ae9aeb 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d.js @@ -31,6 +31,7 @@ * * @example * var Float64Array = require( '@stdlib/array/float64' ); +* var Uint8Array = require( '@stdlib/array/uint8' ); * * // Define the shape of the array: * var shape = [ 2, 2 ]; @@ -54,8 +55,8 @@ * }; * * var mask = { -* 'dtype': 'float64', -* 'data': new Float64Array( [ 1, 0, 1, 0 ] ), +* 'dtype': 'uint8', +* 'data': new Uint8Array( [ 1, 0, 1, 0 ] ), * 'shape': shape, * 'strides': sm, * 'offset': om, diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_accessors.js index bab42438555..e54ea8fbff1 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_accessors.js @@ -79,7 +79,7 @@ * * var y = { * 'dtype': 'complex64', -* 'data': new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ), +* 'data': new Complex64Array( 2 ), * 'shape': [ 2 ], * 'strides': sy, * 'offset': 0, diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked.js index 71820210c17..11166656970 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked.js @@ -37,6 +37,7 @@ var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); * * @example * var Float64Array = require( '@stdlib/array/float64' ); +* var Uint8Array = require( '@stdlib/array/uint8' ); * * // Define the shape of the array: * var shape = [ 2, 2 ]; @@ -60,8 +61,8 @@ var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); * }; * * var mask = { -* 'dtype': 'float64', -* 'data': new Float64Array( [ 1, 0, 1, 0 ] ), +* 'dtype': 'uint8', +* 'data': new Uint8Array( [ 1, 0, 1, 0 ] ), * 'shape': shape, * 'strides': sm, * 'offset': om, diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked_accessors.js index 9984bf7fbb6..64d4c527908 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked_accessors.js @@ -85,7 +85,7 @@ var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); * * var y = { * 'dtype': 'complex64', -* 'data': new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ), +* 'data': new Complex64Array( 2 ), * 'shape': [ 2 ], * 'strides': sy, * 'offset': 0, From f531567cc48ebe913e52b56e0877dfc1d10d99f0 Mon Sep 17 00:00:00 2001 From: Jaysukh-409 Date: Fri, 2 Aug 2024 12:34:53 +0530 Subject: [PATCH 08/34] refactor: update variable name for consistent naming convention --- .../ndarray/base/mskfilter/lib/1d_accessors.js | 16 ++++++++-------- .../ndarray/base/mskfilter/lib/2d_accessors.js | 16 ++++++++-------- .../base/mskfilter/lib/2d_blocked_accessors.js | 16 ++++++++-------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d_accessors.js index 63cc6e77a7b..3f12e0976ab 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d_accessors.js @@ -102,9 +102,9 @@ function mskfilter1d( x, mask, y ) { var xbuf; var mbuf; var ybuf; - var getm; - var getx; - var sety; + var mget; + var xget; + var yset; var dx0; var dm0; var dy0; @@ -131,14 +131,14 @@ function mskfilter1d( x, mask, y ) { ybuf = y.data; // Cache accessors: - getx = x.accessors[ 0 ]; - getm = mask.accessors[ 0 ]; - sety = y.accessors[ 1 ]; + xget = x.accessors[ 0 ]; + mget = mask.accessors[ 0 ]; + yset = y.accessors[ 1 ]; // Iterate over the ndarray dimensions... for ( i0 = 0; i0 < S0; i0++ ) { - if ( getm( mbuf, im ) ) { - sety( ybuf, iy, getx( xbuf, ix ) ); + if ( mget( mbuf, im ) ) { + yset( ybuf, iy, xget( xbuf, ix ) ); iy += dy0; } ix += dx0; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_accessors.js index e54ea8fbff1..74422f7a3c4 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_accessors.js @@ -102,9 +102,9 @@ function mskfilter2d( x, mask, y ) { var xbuf; var mbuf; var ybuf; - var getx; - var getm; - var sety; + var xget; + var mget; + var yset; var dx0; var dx1; var dm0; @@ -155,15 +155,15 @@ function mskfilter2d( x, mask, y ) { ybuf = y.data; // Cache accessors: - getx = x.accessors[ 0 ]; - getm = mask.accessors[ 0 ]; - sety = y.accessors[ 1 ]; + xget = x.accessors[ 0 ]; + mget = mask.accessors[ 0 ]; + yset = y.accessors[ 1 ]; // Iterate over the ndarray dimensions... for ( i1 = 0; i1 < S1; i1++ ) { for ( i0 = 0; i0 < S0; i0++ ) { - if ( getm( mbuf, im ) ) { - sety( ybuf, iy, getx( xbuf, ix ) ); + if ( mget( mbuf, im ) ) { + yset( ybuf, iy, xget( xbuf, ix ) ); iy += dy0; } ix += dx0; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked_accessors.js index 64d4c527908..97a98538463 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked_accessors.js @@ -109,9 +109,9 @@ function blockedmskfilter2d( x, mask, y ) { var xbuf; var mbuf; var ybuf; - var getx; - var getm; - var sety; + var xget; + var mget; + var yset; var dx0; var dx1; var dm0; @@ -161,9 +161,9 @@ function blockedmskfilter2d( x, mask, y ) { iy = y.offset; // Cache accessors: - getx = x.accessors[ 0 ]; - getm = mask.accessors[ 0 ]; - sety = y.accessors[ 1 ]; + xget = x.accessors[ 0 ]; + mget = mask.accessors[ 0 ]; + yset = y.accessors[ 1 ]; // Iterate over blocks... for ( j1 = sh[1]; j1 > 0; ) { @@ -195,8 +195,8 @@ function blockedmskfilter2d( x, mask, y ) { // Iterate over the ndarray dimensions... for ( i1 = 0; i1 < s1; i1++ ) { for ( i0 = 0; i0 < s0; i0++ ) { - if ( getm( mbuf, im ) ) { - sety( ybuf, iy, getx( xbuf, ix ) ); + if ( mget( mbuf, im ) ) { + yset( ybuf, iy, xget( xbuf, ix ) ); iy += dy0; } ix += dx0; From 8ff83b43f850999b91d10634453d4e81e2394e03 Mon Sep 17 00:00:00 2001 From: Jaysukh-409 Date: Sat, 3 Aug 2024 17:04:17 +0530 Subject: [PATCH 09/34] feat: add kernels for 3d ndarray --- .../@stdlib/ndarray/base/mskfilter/lib/3d.js | 165 ++++++++++++ .../base/mskfilter/lib/3d_accessors.js | 203 ++++++++++++++ .../ndarray/base/mskfilter/lib/3d_blocked.js | 210 +++++++++++++++ .../mskfilter/lib/3d_blocked_accessors.js | 248 ++++++++++++++++++ .../ndarray/base/mskfilter/lib/main.js | 59 +++-- 5 files changed, 861 insertions(+), 24 deletions(-) create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_blocked.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_blocked_accessors.js diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d.js new file mode 100644 index 00000000000..6510121bcb7 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d.js @@ -0,0 +1,165 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MAIN // + +/** +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {Object} mask - object containing mask ndarray meta data +* @param {Object} y - object containing output ndarray meta data +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Uint8Array = require( '@stdlib/array/uint8' ); +* +* // Define the shape of the array: +* var shape = [ 3, 1, 2 ]; +* +* // Define the array strides: +* var sx = [ 4, 4, 1 ]; +* var sm = [ 2, 2, 1 ]; +* var sy = [ 1 ]; +* +* // Define the index offset: +* var ox = 1; +* var om = 0; +* +* var x = { +* 'dtype': 'float64', +* 'data': 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 ] ), +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* var mask = { +* 'dtype': 'uint8', +* 'data': new Uint8Array( [ 1, 0, 1, 0, 1, 0 ] ), +* 'shape': shape, +* 'strides': sm, +* 'offset': om, +* 'order': 'row-major' +* }; +* +* var y = { +* 'dtype': 'float64', +* 'data': new Float64Array( 3 ), +* 'shape': [ 3 ], +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major' +* }; +* +* mskfilter3d( x, mask, y ); +* +* console.log( y.data ); +* // => [ 2.0, 6.0, 10.0 ] +*/ +function mskfilter3d( x, mask, y ) { + var xbuf; + var mbuf; + var ybuf; + var dx0; + var dx1; + var dx2; + var dm0; + var dm1; + var dm2; + var dy0; + var S0; + var S1; + var S2; + var sh; + var sm; + var sx; + var ix; + var im; + var iy; + var i0; + var i1; + var i2; + + // Extract loop variables: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + sm = mask.strides; + if ( x.order === 'row-major' ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 2 ]; + S1 = sh[ 1 ]; + S2 = sh[ 0 ]; + dx0 = sx[ 2 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[2] ); + dx2 = sx[ 0 ] - ( S1*sx[1] ); // offset increment for outermost loop + dm0 = sm[ 2 ]; + dm1 = sm[ 1 ] - ( S0*sm[2] ); + dm2 = sm[ 0 ] - ( S1*sm[1] ); + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + S2 = sh[ 2 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); + dx2 = sx[ 2 ] - ( S1*sx[1] ); // offset increment for outermost loop + dm0 = sm[ 0 ]; + dm1 = sm[ 1 ] - ( S0*sm[0] ); + dm2 = sm[ 2 ] - ( S1*sm[1] ); + } + dy0 = y.strides[ 0 ]; + + // Set the pointers to the first indexed elements in the respective ndarrays... + ix = x.offset; + im = mask.offset; + iy = y.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + mbuf = mask.data; + ybuf = y.data; + + // Iterate over the ndarray dimensions... + for ( i2 = 0; i2 < S2; i2++ ) { + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( mbuf[ im ] ) { + ybuf[ iy ] = xbuf[ ix ]; + iy += dy0; + } + ix += dx0; + im += dm0; + } + ix += dx1; + im += dm1; + } + ix += dx2; + im += dm2; + } +} + + +// EXPORTS // + +module.exports = mskfilter3d; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_accessors.js new file mode 100644 index 00000000000..970d06848bc --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_accessors.js @@ -0,0 +1,203 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MAIN // + +/** +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {Object} mask - object containing mask ndarray meta data +* @param {Object} y - object containing output ndarray meta data +* @returns {void} +* +* @example +* var BooleanArray = require( '@stdlib/array/bool' ); +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* var realf = require( '@stdlib/complex/realf' ); +* var imagf = require( '@stdlib/complex/imagf' ); +* +* // Define the shape of the array: +* var shape = [ 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 2, 2, 1 ]; +* var sm = [ 2, 2, 1 ]; +* var sy = [ 1 ]; +* +* // Define the index offset: +* var ox = 0; +* var om = 0; +* +* // Define getters and setters: +* function getter( buf, idx ) { +* return buf.get( idx ); +* } +* +* function setter( buf, idx, value ) { +* buf.set( value, idx ); +* } +* +* var x = { +* 'dtype': 'complex64', +* 'data': new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ), +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* var mask = { +* 'dtype': 'bool', +* 'data': new BooleanArray( [ 1, 0, 1, 0 ] ), +* 'shape': shape, +* 'strides': sm, +* 'offset': om, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* var y = { +* 'dtype': 'complex64', +* 'data': new Complex64Array( 2 ), +* 'shape': [ 2 ], +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* mskfilter3d( x, mask, y ); +* +* var v = y.data.get( 0 ); +* // returns +* +* var re = realf( v ); +* // returns 1.0 +* +* var im = imagf( v ); +* // returns 2.0 +* +* v = y.data.get( 1 ); +* // returns +* +* re = realf( v ); +* // returns 5.0 +* +* im = imagf( v ); +* // returns 6.0 +*/ +function mskfilter3d( x, mask, y ) { + var xbuf; + var mbuf; + var ybuf; + var xget; + var mget; + var yset; + var dx0; + var dx1; + var dx2; + var dm0; + var dm1; + var dm2; + var dy0; + var S0; + var S1; + var S2; + var sh; + var sm; + var sx; + var ix; + var im; + var iy; + var i0; + var i1; + var i2; + + // Extract loop variables: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + sm = mask.strides; + if ( x.order === 'row-major' ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 2 ]; + S1 = sh[ 1 ]; + S2 = sh[ 0 ]; + dx0 = sx[ 2 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[2] ); + dx2 = sx[ 0 ] - ( S1*sx[1] ); // offset increment for outermost loop + dm0 = sm[ 2 ]; + dm1 = sm[ 1 ] - ( S0*sm[2] ); + dm2 = sm[ 0 ] - ( S1*sm[1] ); + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + S2 = sh[ 2 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); + dx2 = sx[ 2 ] - ( S1*sx[1] ); // offset increment for outermost loop + dm0 = sm[ 0 ]; + dm1 = sm[ 1 ] - ( S0*sm[0] ); + dm2 = sm[ 2 ] - ( S1*sm[1] ); + } + dy0 = y.strides[ 0 ]; + + // Set the pointers to the first indexed elements in the respective ndarrays... + ix = x.offset; + im = mask.offset; + iy = y.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + mbuf = mask.data; + ybuf = y.data; + + // Cache accessors: + xget = x.accessors[ 0 ]; + mget = mask.accessors[ 0 ]; + yset = y.accessors[ 1 ]; + + // Iterate over the ndarray dimensions... + for ( i2 = 0; i2 < S2; i2++ ) { + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( mget( mbuf, im ) ) { + yset( ybuf, iy, xget( xbuf, ix ) ); + iy += dy0; + } + ix += dx0; + im += dm0; + } + ix += dx1; + im += dm1; + } + ix += dx2; + im += dm2; + } +} + + +// EXPORTS // + +module.exports = mskfilter3d; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_blocked.js new file mode 100644 index 00000000000..542f7067dc1 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_blocked.js @@ -0,0 +1,210 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/unary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); + + +// MAIN // + +/** +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {Object} mask - object containing mask ndarray meta data +* @param {Object} y - object containing output ndarray meta data +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Uint8Array = require( '@stdlib/array/uint8' ); +* +* // Define the shape of the array: +* var shape = [ 3, 1, 2 ]; +* +* // Define the array strides: +* var sx = [ 4, 4, 1 ]; +* var sm = [ 2, 2, 1 ]; +* var sy = [ 1 ]; +* +* // Define the index offset: +* var ox = 1; +* var om = 0; +* +* var x = { +* 'dtype': 'float64', +* 'data': 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 ] ), +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* var mask = { +* 'dtype': 'uint8', +* 'data': new Uint8Array( [ 1, 0, 1, 0, 1, 0 ] ), +* 'shape': shape, +* 'strides': sm, +* 'offset': om, +* 'order': 'row-major' +* }; +* +* var y = { +* 'dtype': 'float64', +* 'data': new Float64Array( 3 ), +* 'shape': [ 3 ], +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major' +* }; +* +* blockedmskfilter3d( x, mask, y ); +* +* console.log( y.data ); +* // => [ 2.0, 6.0, 10.0 ] +*/ +function blockedmskfilter3d( x, mask, y ) { + var bsize; + var xbuf; + var mbuf; + var ybuf; + var dx0; + var dx1; + var dx2; + var dm0; + var dm1; + var dm2; + var dy0; + var ox1; + var ox2; + var om1; + var om2; + var sh; + var s0; + var s1; + var s2; + var sx; + var sm; + var ox; + var om; + var ix; + var im; + var iy; + var i0; + var i1; + var i2; + var j0; + var j1; + var j2; + var o; + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides, mask.strides ); + sh = o.sh; + sx = o.sx; + sm = o.sy; + + // Determine the block size: + bsize = blockSize( x.dtype, mask.dtype ); + + // Cache the indices of the first indexed elements in the respective ndarrays... + ox = x.offset; + om = mask.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + mbuf = mask.data; + ybuf = y.data; + + // Cache offset increments for the innermost loop... + dx0 = sx[0]; + dm0 = sm[0]; + dy0 = y.strides[0]; + + iy = y.offset; + + // Iterate over blocks... + for ( j2 = sh[2]; j2 > 0; ) { + if ( j2 < bsize ) { + s2 = j2; + j2 = 0; + } else { + s2 = bsize; + j2 -= bsize; + } + ox2 = ox + ( j2*sx[2] ); + om2 = om + ( j2*sm[2] ); + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + dx2 = sx[2] - ( s1*sx[1] ); + dm2 = sm[2] - ( s1*sm[1] ); + ox1 = ox2 + ( j1*sx[1] ); + om1 = om2 + ( j1*sm[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute index offsets for the first input and output ndarray elements in the current block... + ix = ox1 + ( j0*sx[0] ); + im = om1 + ( j0*sm[0] ); + + // Compute loop offset increments... + dx1 = sx[1] - ( s0*sx[0] ); + dm1 = sm[1] - ( s0*sm[0] ); + + // Iterate over the ndarray dimensions... + for ( i2 = 0; i2 < s2; i2++ ) { + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( mbuf[ im ] ) { + ybuf[ iy ] = xbuf[ ix ]; + iy += dy0; + } + ix += dx0; + im += dm0; + } + ix += dx1; + im += dm1; + } + ix += dx2; + im += dm2; + } + } + } + } +} + + +// EXPORTS // + +module.exports = blockedmskfilter3d; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_blocked_accessors.js new file mode 100644 index 00000000000..a71c75a0510 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_blocked_accessors.js @@ -0,0 +1,248 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/unary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); + + +// MAIN // + +/** +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {Object} mask - object containing mask ndarray meta data +* @param {Object} y - object containing output ndarray meta data +* @returns {void} +* +* @example +* var BooleanArray = require( '@stdlib/array/bool' ); +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* var realf = require( '@stdlib/complex/realf' ); +* var imagf = require( '@stdlib/complex/imagf' ); +* +* // Define the shape of the array: +* var shape = [ 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 2, 2, 1 ]; +* var sm = [ 2, 2, 1 ]; +* var sy = [ 1 ]; +* +* // Define the index offset: +* var ox = 0; +* var om = 0; +* +* // Define getters and setters: +* function getter( buf, idx ) { +* return buf.get( idx ); +* } +* +* function setter( buf, idx, value ) { +* buf.set( value, idx ); +* } +* +* var x = { +* 'dtype': 'complex64', +* 'data': new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ), +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* var mask = { +* 'dtype': 'bool', +* 'data': new BooleanArray( [ 1, 0, 1, 0 ] ), +* 'shape': shape, +* 'strides': sm, +* 'offset': om, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* var y = { +* 'dtype': 'complex64', +* 'data': new Complex64Array( 2 ), +* 'shape': [ 2 ], +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* blockedmskfilter3d( x, mask, y ); +* +* var v = y.data.get( 0 ); +* // returns +* +* var re = realf( v ); +* // returns 1.0 +* +* var im = imagf( v ); +* // returns 2.0 +* +* v = y.data.get( 1 ); +* // returns +* +* re = realf( v ); +* // returns 5.0 +* +* im = imagf( v ); +* // returns 6.0 +*/ +function blockedmskfilter3d( x, mask, y ) { + var bsize; + var xbuf; + var mbuf; + var ybuf; + var xget; + var mget; + var yset; + var dx0; + var dx1; + var dx2; + var dm0; + var dm1; + var dm2; + var dy0; + var ox1; + var ox2; + var om1; + var om2; + var sh; + var s0; + var s1; + var s2; + var sx; + var sm; + var ox; + var om; + var ix; + var im; + var iy; + var i0; + var i1; + var i2; + var j0; + var j1; + var j2; + var o; + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides, mask.strides ); + sh = o.sh; + sx = o.sx; + sm = o.sy; + + // Determine the block size: + bsize = blockSize( x.dtype, mask.dtype ); + + // Cache the indices of the first indexed elements in the respective ndarrays... + ox = x.offset; + om = mask.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + mbuf = mask.data; + ybuf = y.data; + + // Cache offset increments for the innermost loop... + dx0 = sx[0]; + dm0 = sm[0]; + dy0 = y.strides[0]; + + iy = y.offset; + + // Cache accessors: + xget = x.accessors[ 0 ]; + mget = mask.accessors[ 0 ]; + yset = y.accessors[ 1 ]; + + // Iterate over blocks... + for ( j2 = sh[2]; j2 > 0; ) { + if ( j2 < bsize ) { + s2 = j2; + j2 = 0; + } else { + s2 = bsize; + j2 -= bsize; + } + ox2 = ox + ( j2*sx[2] ); + om2 = om + ( j2*sm[2] ); + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + dx2 = sx[2] - ( s1*sx[1] ); + dm2 = sm[2] - ( s1*sm[1] ); + ox1 = ox2 + ( j1*sx[1] ); + om1 = om2 + ( j1*sm[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute index offsets for the first input and output ndarray elements in the current block... + ix = ox1 + ( j0*sx[0] ); + im = om1 + ( j0*sm[0] ); + + // Compute loop offset increments... + dx1 = sx[1] - ( s0*sx[0] ); + dm1 = sm[1] - ( s0*sm[0] ); + + // Iterate over the ndarray dimensions... + for ( i2 = 0; i2 < s2; i2++ ) { + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( mget( mbuf, im ) ) { + yset( ybuf, iy, xget( xbuf, ix ) ); + iy += dy0; + } + ix += dx0; + im += dm0; + } + ix += dx1; + im += dm1; + } + ix += dx2; + im += dm2; + } + } + } + } +} + + +// EXPORTS // + +module.exports = blockedmskfilter3d; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js index 3b3ec648492..9a9ec624b46 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js @@ -25,30 +25,44 @@ var ndarray2object = require( '@stdlib/ndarray/base/ndarraylike2object' ); var minmaxViewBufferIndex = require( '@stdlib/ndarray/base/minmax-view-buffer-index' ); var format = require( '@stdlib/string/format' ); var numel = require( '@stdlib/ndarray/base/numel' ); -var accessorMskfilter0d = require( './0d_accessors.js' ); -var accessorMskfilter1d = require( './1d_accessors.js' ); +var blockedaccessormskfilter2d = require( './2d_blocked_accessors.js' ); +var blockedaccessormskfilter3d = require( './3d_blocked_accessors.js' ); +var blockedmskfilter2d = require( './2d_blocked.js' ); +var blockedmskfilter3d = require( './3d_blocked.js' ); +var accessormskfilter0d = require( './0d_accessors.js' ); +var accessormskfilter1d = require( './1d_accessors.js' ); +var accessormskfilter2d = require( './2d_accessors.js' ); +var accessormskfilter3d = require( './3d_accessors.js' ); var mskfilter0d = require( './0d.js' ); var mskfilter1d = require( './1d.js' ); +var mskfilter2d = require( './2d.js' ); +var mskfilter3d = require( './3d.js' ); // VARIABLES // var MSKFILTER = [ mskfilter0d, - mskfilter1d + mskfilter1d, + mskfilter2d, + mskfilter3d ]; var ACCESSOR_MSKFILTER = [ - accessorMskfilter0d, - accessorMskfilter1d + accessormskfilter0d, + accessormskfilter1d, + accessormskfilter2d, + accessormskfilter3d ]; var BLOCKED_MSKFILTER = [ - + blockedmskfilter2d, + blockedmskfilter3d ]; var BLOCKED_ACCESSOR_MSKFILTER = [ - + blockedaccessormskfilter2d, + blockedaccessormskfilter3d ]; var MAX_DIMS = MSKFILTER.length - 1; @@ -78,45 +92,42 @@ var MAX_DIMS = MSKFILTER.length - 1; * * @example * var Float64Array = require( '@stdlib/array/float64' ); -* var mskfilter = require( '@stdlib/ndarray/base/mskfilter' ); -* -* // 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 mbuf = new Float64Array( [ 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 ] ); -* var ybuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var Uint8Array = require( '@stdlib/array/uint8' ); * * // Define the shape of the input and mask arrays: * var shape = [ 3, 1, 2 ]; * * // Define the array strides: -* var s = [ 4, 4, 1 ]; +* var sx = [ 4, 4, 1 ]; +* var sm = [ 2, 2, 1 ]; +* var sy = [ 1 ]; * * // Define the index offsets: -* var ox = 0; +* var ox = 1; * var om = 0; * * // Create the input, mask and output ndarray-like objects: * var x = { * 'dtype': 'float64', -* 'data': xbuf, +* 'data': 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 ] ), * 'shape': shape, -* 'strides': s, +* 'strides': sx, * 'offset': ox, * 'order': 'row-major' * }; * var mask = { -* 'dtype': 'float64', -* 'data': mbuf, +* 'dtype': 'uint8', +* 'data': new Uint8Array( [ 1, 0, 1, 0, 1, 0 ] ), * 'shape': shape, -* 'strides': s, +* 'strides': sm, * 'offset': om, * 'order': 'row-major' * }; * var out = { * 'dtype': 'float64', -* 'data': ybuf, -* 'shape': [ 4 ], -* 'strides': [ 1 ], +* 'data': new Float64Array( 3 ), +* 'shape': [ 3 ], +* 'strides': sy, * 'offset': 0, * 'order': 'row-major' * }; @@ -125,7 +136,7 @@ var MAX_DIMS = MSKFILTER.length - 1; * mskfilter( [ x, mask, out ] ); * * console.log( out.data ); -* // => [ 1.0, 5.0, 9.0, 11.0 ] +* // => [ 2.0, 6.0, 10.0 ] */ function mskfilter( arrays ) { var ndims; From 4039020c7020a2950d319710851ca7dbb1833448 Mon Sep 17 00:00:00 2001 From: Jaysukh-409 Date: Sat, 3 Aug 2024 17:39:01 +0530 Subject: [PATCH 10/34] feat: add kernels for nd ndarray --- .../ndarray/base/mskfilter/lib/main.js | 8 +- .../@stdlib/ndarray/base/mskfilter/lib/nd.js | 150 ++++++++++++++ .../base/mskfilter/lib/nd_accessors.js | 188 ++++++++++++++++++ 3 files changed, 343 insertions(+), 3 deletions(-) create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/nd.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/nd_accessors.js diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js index 9a9ec624b46..d146fe7de5c 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js @@ -33,10 +33,12 @@ var accessormskfilter0d = require( './0d_accessors.js' ); var accessormskfilter1d = require( './1d_accessors.js' ); var accessormskfilter2d = require( './2d_accessors.js' ); var accessormskfilter3d = require( './3d_accessors.js' ); +var accessormskfilternd = require( './nd_accessors.js' ); var mskfilter0d = require( './0d.js' ); var mskfilter1d = require( './1d.js' ); var mskfilter2d = require( './2d.js' ); var mskfilter3d = require( './3d.js' ); +var mskfilternd = require( './nd.js' ); // VARIABLES // @@ -71,7 +73,7 @@ var MAX_DIMS = MSKFILTER.length - 1; // MAIN // /** -* Apply a mask to a provided input ndarray and assign unmasked values to elements in a provided one-dimensional output ndarray. +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. * * ## Notes * @@ -291,9 +293,9 @@ function mskfilter( arrays ) { } // Fall-through to linear view iteration without regard for how data is stored in memory (i.e., take the slow path)... if ( x.accessorProtocol || mask.accessorProtocol || y.accessorProtocol ) { - return accessorassignnd( x, mask, y ); + return accessormskfilternd( x, mask, y ); } - assignnd( x, mask, y ); + mskfilternd( x, mask, y ); } diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/nd.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/nd.js new file mode 100644 index 00000000000..da0c6a49ffe --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/nd.js @@ -0,0 +1,150 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var numel = require( '@stdlib/ndarray/base/numel' ); +var vind2bind = require( '@stdlib/ndarray/base/vind2bind' ); + + +// VARIABLES // + +var MODE = 'throw'; + + +// MAIN // + +/** +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {Object} mask - object containing mask ndarray meta data +* @param {Object} y - object containing output ndarray meta data +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Uint8Array = require( '@stdlib/array/uint8' ); +* +* // Define the shape of the array: +* var shape = [ 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 4, 1 ]; +* var sm = [ 2, 1 ]; +* var sy = [ 1 ]; +* +* // Define the index offset: +* var ox = 1; +* var om = 0; +* +* var x = { +* 'dtype': 'float64', +* 'data': new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ), +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* var mask = { +* 'dtype': 'uint8', +* 'data': new Uint8Array( [ 1, 0, 1, 0 ] ), +* 'shape': shape, +* 'strides': sm, +* 'offset': om, +* 'order': 'row-major' +* }; +* +* var y = { +* 'dtype': 'float64', +* 'data': new Float64Array( 2 ), +* 'shape': [ 2 ], +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major' +* }; +* +* mskfilternd( x, mask, y ); +* +* console.log( y.data ); +* // => [ 2.0, 6.0 ] +*/ +function mskfilternd( x, mask, y ) { + var xbuf; + var mbuf; + var ybuf; + var ordx; + var ordm; + var len; + var sh; + var sx; + var sm; + var dy; + var ox; + var om; + var oy; + var ix; + var im; + var iy; + var i; + + sh = x.shape; + + // Compute the total number of elements over which to iterate: + len = numel( sh ); + + // Cache references to the input and output ndarray data buffers: + xbuf = x.data; + mbuf = mask.data; + ybuf = y.data; + + // Cache references to the respective stride arrays: + sx = x.strides; + sm = mask.strides; + dy = y.strides[ 0 ]; + + // Cache the indices of the first indexed elements in the respective ndarrays: + ox = x.offset; + om = mask.offset; + oy = y.offset; + + // Cache the respective array orders: + ordx = x.order; + ordm = mask.order; + + iy = oy; + + // Iterate over each element based on the linear **view** index, regardless as to how the data is stored in memory... + for ( i = 0; i < len; i++ ) { + ix = vind2bind( sh, sx, ox, ordx, i, MODE ); + im = vind2bind( sh, sm, om, ordm, i, MODE ); + if ( mbuf[ im ] ) { + ybuf[ iy ] = xbuf[ ix ]; + iy += dy; + } + } +} + + +// EXPORTS // + +module.exports = mskfilternd; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/nd_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/nd_accessors.js new file mode 100644 index 00000000000..785dacb5853 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/nd_accessors.js @@ -0,0 +1,188 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var numel = require( '@stdlib/ndarray/base/numel' ); +var vind2bind = require( '@stdlib/ndarray/base/vind2bind' ); + + +// VARIABLES // + +var MODE = 'throw'; + + +// MAIN // + +/** +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {Object} mask - object containing mask ndarray meta data +* @param {Object} y - object containing output ndarray meta data +* @returns {void} +* +* @example +* var BooleanArray = require( '@stdlib/array/bool' ); +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* var realf = require( '@stdlib/complex/realf' ); +* var imagf = require( '@stdlib/complex/imagf' ); +* +* // Define the shape of the array: +* var shape = [ 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 2, 1 ]; +* var sm = [ 2, 1 ]; +* var sy = [ 1 ]; +* +* // Define the index offset: +* var ox = 0; +* var om = 0; +* +* // Define getters and setters: +* function getter( buf, idx ) { +* return buf.get( idx ); +* } +* +* function setter( buf, idx, value ) { +* buf.set( value, idx ); +* } +* +* var x = { +* 'dtype': 'complex64', +* 'data': new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ), +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* var mask = { +* 'dtype': 'bool', +* 'data': new BooleanArray( [ 1, 0, 1, 0 ] ), +* 'shape': shape, +* 'strides': sm, +* 'offset': om, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* var y = { +* 'dtype': 'complex64', +* 'data': new Complex64Array( 2 ), +* 'shape': [ 2 ], +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* mskfilternd( x, mask, y ); +* +* var v = y.data.get( 0 ); +* // returns +* +* var re = realf( v ); +* // returns 1.0 +* +* var im = imagf( v ); +* // returns 2.0 +* +* v = y.data.get( 1 ); +* // returns +* +* re = realf( v ); +* // returns 5.0 +* +* im = imagf( v ); +* // returns 6.0 +*/ +function mskfilternd( x, mask, y ) { + var xbuf; + var mbuf; + var ybuf; + var xget; + var mget; + var yset; + var ordx; + var ordm; + var len; + var sh; + var sx; + var sm; + var dy; + var ox; + var om; + var oy; + var ix; + var im; + var iy; + var i; + + sh = x.shape; + + // Compute the total number of elements over which to iterate: + len = numel( sh ); + + // Cache references to the input and output ndarray data buffers: + xbuf = x.data; + mbuf = mask.data; + ybuf = y.data; + + // Cache references to the respective stride arrays: + sx = x.strides; + sm = mask.strides; + dy = y.strides[ 0 ]; + + // Cache the indices of the first indexed elements in the respective ndarrays: + ox = x.offset; + om = mask.offset; + oy = y.offset; + + // Cache the respective array orders: + ordx = x.order; + ordm = mask.order; + + // Cache accessors: + xget = x.accessors[ 0 ]; + mget = mask.accessors[ 0 ]; + yset = y.accessors[ 1 ]; + + iy = oy; + + // Iterate over each element based on the linear **view** index, regardless as to how the data is stored in memory... + for ( i = 0; i < len; i++ ) { + ix = vind2bind( sh, sx, ox, ordx, i, MODE ); + im = vind2bind( sh, sm, om, ordm, i, MODE ); + if ( mget( mbuf, im ) ) { + yset( ybuf, iy, xget( xbuf, ix ) ); + iy += dy; + } + } +} + + +// EXPORTS // + +module.exports = mskfilternd; From 9422eb59c6bbd45af4968e2a148d07cafb9157af Mon Sep 17 00:00:00 2001 From: Jaysukh-409 Date: Mon, 5 Aug 2024 11:37:06 +0530 Subject: [PATCH 11/34] feat: add kernels for 4d ndarray --- .../ndarray/base/mskfilter/lib/3d_blocked.js | 2 + .../mskfilter/lib/3d_blocked_accessors.js | 2 + .../@stdlib/ndarray/base/mskfilter/lib/4d.js | 179 ++++++++++++ .../base/mskfilter/lib/4d_accessors.js | 217 ++++++++++++++ .../ndarray/base/mskfilter/lib/4d_blocked.js | 236 +++++++++++++++ .../mskfilter/lib/4d_blocked_accessors.js | 274 ++++++++++++++++++ 6 files changed, 910 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_blocked.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_blocked_accessors.js diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_blocked.js index 542f7067dc1..d5e3a2c368a 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_blocked.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_blocked.js @@ -16,6 +16,8 @@ * limitations under the License. */ +/* eslint-disable max-depth */ + 'use strict'; // MODULES // diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_blocked_accessors.js index a71c75a0510..46906777637 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_blocked_accessors.js @@ -16,6 +16,8 @@ * limitations under the License. */ +/* eslint-disable max-depth */ + 'use strict'; // MODULES // diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d.js new file mode 100644 index 00000000000..6804d1af897 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d.js @@ -0,0 +1,179 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MAIN // + +/** +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {Object} mask - object containing mask ndarray meta data +* @param {Object} y - object containing output ndarray meta data +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Uint8Array = require( '@stdlib/array/uint8' ); +* +* // Define the shape of the array: +* var shape = [ 1, 3, 1, 2 ]; +* +* // Define the array strides: +* var sx = [ 12, 4, 4, 1 ]; +* var sm = [ 6, 2, 2, 1 ]; +* var sy = [ 1 ]; +* +* // Define the index offset: +* var ox = 1; +* var om = 0; +* +* var x = { +* 'dtype': 'float64', +* 'data': 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 ] ), +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* var mask = { +* 'dtype': 'uint8', +* 'data': new Uint8Array( [ 1, 0, 1, 0, 1, 0 ] ), +* 'shape': shape, +* 'strides': sm, +* 'offset': om, +* 'order': 'row-major' +* }; +* +* var y = { +* 'dtype': 'float64', +* 'data': new Float64Array( 3 ), +* 'shape': [ 3 ], +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major' +* }; +* +* mskfilter4d( x, mask, y ); +* +* console.log( y.data ); +* // => [ 2.0, 6.0, 10.0 ] +*/ +function mskfilter4d( x, mask, y ) { + var xbuf; + var mbuf; + var ybuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dm0; + var dm1; + var dm2; + var dm3; + var dy0; + var S0; + var S1; + var S2; + var S3; + var sh; + var sm; + var sx; + var ix; + var im; + var iy; + var i0; + var i1; + var i2; + var i3; + + // Extract loop variables: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + sm = mask.strides; + if ( x.order === 'row-major' ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 3 ]; + S1 = sh[ 2 ]; + S2 = sh[ 1 ]; + S3 = sh[ 0 ]; + dx0 = sx[ 3 ]; // offset increment for innermost loop + dx1 = sx[ 2 ] - ( S0*sx[3] ); + dx2 = sx[ 1 ] - ( S1*sx[2] ); + dx3 = sx[ 0 ] - ( S2*sx[1] ); // offset increment for outermost loop + dm0 = sm[ 3 ]; + dm1 = sm[ 2 ] - ( S0*sm[3] ); + dm2 = sm[ 1 ] - ( S1*sm[2] ); + dm3 = sm[ 0 ] - ( S2*sm[1] ); + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + S2 = sh[ 2 ]; + S3 = sh[ 3 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); + dx2 = sx[ 2 ] - ( S1*sx[1] ); + dx3 = sx[ 3 ] - ( S2*sx[2] ); // offset increment for outermost loop + dm0 = sm[ 0 ]; + dm1 = sm[ 1 ] - ( S0*sm[0] ); + dm2 = sm[ 2 ] - ( S1*sm[1] ); + dm3 = sm[ 3 ] - ( S2*sm[2] ); + } + dy0 = y.strides[ 0 ]; + + // Set the pointers to the first indexed elements in the respective ndarrays... + ix = x.offset; + im = mask.offset; + iy = y.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + mbuf = mask.data; + ybuf = y.data; + + // Iterate over the ndarray dimensions... + for ( i3 = 0; i3 < S3; i3++ ) { + for ( i2 = 0; i2 < S2; i2++ ) { + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( mbuf[ im ] ) { + ybuf[ iy ] = xbuf[ ix ]; + iy += dy0; + } + ix += dx0; + im += dm0; + } + ix += dx1; + im += dm1; + } + ix += dx2; + im += dm2; + } + ix += dx3; + im += dm3; + } +} + + +// EXPORTS // + +module.exports = mskfilter4d; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_accessors.js new file mode 100644 index 00000000000..8bd147352df --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_accessors.js @@ -0,0 +1,217 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MAIN // + +/** +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {Object} mask - object containing mask ndarray meta data +* @param {Object} y - object containing output ndarray meta data +* @returns {void} +* +* @example +* var BooleanArray = require( '@stdlib/array/bool' ); +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* var realf = require( '@stdlib/complex/realf' ); +* var imagf = require( '@stdlib/complex/imagf' ); +* +* // Define the shape of the array: +* var shape = [ 1, 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 2, 2, 2, 1 ]; +* var sm = [ 2, 2, 2, 1 ]; +* var sy = [ 1 ]; +* +* // Define the index offset: +* var ox = 0; +* var om = 0; +* +* // Define getters and setters: +* function getter( buf, idx ) { +* return buf.get( idx ); +* } +* +* function setter( buf, idx, value ) { +* buf.set( value, idx ); +* } +* +* var x = { +* 'dtype': 'complex64', +* 'data': new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ), +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* var mask = { +* 'dtype': 'bool', +* 'data': new BooleanArray( [ 1, 0, 1, 0 ] ), +* 'shape': shape, +* 'strides': sm, +* 'offset': om, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* var y = { +* 'dtype': 'complex64', +* 'data': new Complex64Array( 2 ), +* 'shape': [ 2 ], +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* mskfilter4d( x, mask, y ); +* +* var v = y.data.get( 0 ); +* // returns +* +* var re = realf( v ); +* // returns 1.0 +* +* var im = imagf( v ); +* // returns 2.0 +* +* v = y.data.get( 1 ); +* // returns +* +* re = realf( v ); +* // returns 5.0 +* +* im = imagf( v ); +* // returns 6.0 +*/ +function mskfilter4d( x, mask, y ) { + var xbuf; + var mbuf; + var ybuf; + var xget; + var mget; + var yset; + var dx0; + var dx1; + var dx2; + var dx3; + var dm0; + var dm1; + var dm2; + var dm3; + var dy0; + var S0; + var S1; + var S2; + var S3; + var sh; + var sm; + var sx; + var ix; + var im; + var iy; + var i0; + var i1; + var i2; + var i3; + + // Extract loop variables: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + sm = mask.strides; + if ( x.order === 'row-major' ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 3 ]; + S1 = sh[ 2 ]; + S2 = sh[ 1 ]; + S3 = sh[ 0 ]; + dx0 = sx[ 3 ]; // offset increment for innermost loop + dx1 = sx[ 2 ] - ( S0*sx[3] ); + dx2 = sx[ 1 ] - ( S1*sx[2] ); + dx3 = sx[ 0 ] - ( S2*sx[1] ); // offset increment for outermost loop + dm0 = sm[ 3 ]; + dm1 = sm[ 2 ] - ( S0*sm[3] ); + dm2 = sm[ 1 ] - ( S1*sm[2] ); + dm3 = sm[ 0 ] - ( S2*sm[1] ); + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + S2 = sh[ 2 ]; + S3 = sh[ 3 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); + dx2 = sx[ 2 ] - ( S1*sx[1] ); + dx3 = sx[ 3 ] - ( S2*sx[2] ); // offset increment for outermost loop + dm0 = sm[ 0 ]; + dm1 = sm[ 1 ] - ( S0*sm[0] ); + dm2 = sm[ 2 ] - ( S1*sm[1] ); + dm3 = sm[ 3 ] - ( S2*sm[2] ); + } + dy0 = y.strides[ 0 ]; + + // Set the pointers to the first indexed elements in the respective ndarrays... + ix = x.offset; + im = mask.offset; + iy = y.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + mbuf = mask.data; + ybuf = y.data; + + // Cache accessors: + xget = x.accessors[ 0 ]; + mget = mask.accessors[ 0 ]; + yset = y.accessors[ 1 ]; + + // Iterate over the ndarray dimensions... + for ( i3 = 0; i3 < S3; i3++ ) { + for ( i2 = 0; i2 < S2; i2++ ) { + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( mget( mbuf, im ) ) { + yset( ybuf, iy, xget( xbuf, ix ) ); + iy += dy0; + } + ix += dx0; + im += dm0; + } + ix += dx1; + im += dm1; + } + ix += dx2; + im += dm2; + } + ix += dx3; + im += dm3; + } +} + + +// EXPORTS // + +module.exports = mskfilter4d; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_blocked.js new file mode 100644 index 00000000000..c7414945d2b --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_blocked.js @@ -0,0 +1,236 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-depth */ + +'use strict'; + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/unary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); + + +// MAIN // + +/** +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {Object} mask - object containing mask ndarray meta data +* @param {Object} y - object containing output ndarray meta data +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Uint8Array = require( '@stdlib/array/uint8' ); +* +* // Define the shape of the array: +* var shape = [ 1, 3, 1, 2 ]; +* +* // Define the array strides: +* var sx = [ 12, 4, 4, 1 ]; +* var sm = [ 6, 2, 2, 1 ]; +* var sy = [ 1 ]; +* +* // Define the index offset: +* var ox = 1; +* var om = 0; +* +* var x = { +* 'dtype': 'float64', +* 'data': 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 ] ), +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* var mask = { +* 'dtype': 'uint8', +* 'data': new Uint8Array( [ 1, 0, 1, 0, 1, 0 ] ), +* 'shape': shape, +* 'strides': sm, +* 'offset': om, +* 'order': 'row-major' +* }; +* +* var y = { +* 'dtype': 'float64', +* 'data': new Float64Array( 3 ), +* 'shape': [ 3 ], +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major' +* }; +* +* blockedmskfilter4d( x, mask, y ); +* +* console.log( y.data ); +* // => [ 2.0, 6.0, 10.0 ] +*/ +function blockedmskfilter4d( x, mask, y ) { // eslint-disable-line max-statements + var bsize; + var xbuf; + var mbuf; + var ybuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dm0; + var dm1; + var dm2; + var dm3; + var dy0; + var ox1; + var ox2; + var ox3; + var om1; + var om2; + var om3; + var sh; + var s0; + var s1; + var s2; + var s3; + var sx; + var sm; + var ox; + var om; + var ix; + var im; + var iy; + var i0; + var i1; + var i2; + var i3; + var j0; + var j1; + var j2; + var j3; + var o; + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides, mask.strides ); + sh = o.sh; + sx = o.sx; + sm = o.sy; + + // Determine the block size: + bsize = blockSize( x.dtype, mask.dtype ); + + // Cache the indices of the first indexed elements in the respective ndarrays... + ox = x.offset; + om = mask.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + mbuf = mask.data; + ybuf = y.data; + + // Cache offset increments for the innermost loop... + dx0 = sx[0]; + dm0 = sm[0]; + dy0 = y.strides[0]; + + iy = y.offset; + + // Iterate over blocks... + for ( j3 = sh[3]; j3 > 0; ) { + if ( j3 < bsize ) { + s3 = j3; + j3 = 0; + } else { + s3 = bsize; + j3 -= bsize; + } + ox3 = ox + ( j3*sx[3] ); + om3 = om + ( j3*sm[3] ); + for ( j2 = sh[2]; j2 > 0; ) { + if ( j2 < bsize ) { + s2 = j2; + j2 = 0; + } else { + s2 = bsize; + j2 -= bsize; + } + dx3 = sx[3] - ( s2*sx[2] ); + dm3 = sm[3] - ( s2*sm[2] ); + ox2 = ox3 + ( j2*sx[2] ); + om2 = om3 + ( j2*sm[2] ); + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + dx2 = sx[2] - ( s1*sx[1] ); + dm2 = sm[2] - ( s1*sm[1] ); + ox1 = ox2 + ( j1*sx[1] ); + om1 = om2 + ( j1*sm[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute index offsets for the first input and output ndarray elements in the current block... + ix = ox1 + ( j0*sx[0] ); + im = om1 + ( j0*sm[0] ); + + // Compute loop offset increments... + dx1 = sx[1] - ( s0*sx[0] ); + dm1 = sm[1] - ( s0*sm[0] ); + + // Iterate over the ndarray dimensions... + for ( i3 = 0; i3 < s3; i3++ ) { + for ( i2 = 0; i2 < s2; i2++ ) { + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( mbuf[ im ] ) { + ybuf[ iy ] = xbuf[ ix ]; + iy += dy0; + } + ix += dx0; + im += dm0; + } + ix += dx1; + im += dm1; + } + ix += dx2; + im += dm2; + } + ix += dx3; + im += dm3; + } + } + } + } + } +} + + +// EXPORTS // + +module.exports = blockedmskfilter4d; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_blocked_accessors.js new file mode 100644 index 00000000000..af78bf7c093 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_blocked_accessors.js @@ -0,0 +1,274 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-depth */ + +'use strict'; + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/unary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); + + +// MAIN // + +/** +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {Object} mask - object containing mask ndarray meta data +* @param {Object} y - object containing output ndarray meta data +* @returns {void} +* +* @example +* var BooleanArray = require( '@stdlib/array/bool' ); +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* var realf = require( '@stdlib/complex/realf' ); +* var imagf = require( '@stdlib/complex/imagf' ); +* +* // Define the shape of the array: +* var shape = [ 1, 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 2, 2, 2, 1 ]; +* var sm = [ 2, 2, 2, 1 ]; +* var sy = [ 1 ]; +* +* // Define the index offset: +* var ox = 0; +* var om = 0; +* +* // Define getters and setters: +* function getter( buf, idx ) { +* return buf.get( idx ); +* } +* +* function setter( buf, idx, value ) { +* buf.set( value, idx ); +* } +* +* var x = { +* 'dtype': 'complex64', +* 'data': new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ), +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* var mask = { +* 'dtype': 'bool', +* 'data': new BooleanArray( [ 1, 0, 1, 0 ] ), +* 'shape': shape, +* 'strides': sm, +* 'offset': om, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* var y = { +* 'dtype': 'complex64', +* 'data': new Complex64Array( 2 ), +* 'shape': [ 2 ], +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* blockedmskfilter4d( x, mask, y ); +* +* var v = y.data.get( 0 ); +* // returns +* +* var re = realf( v ); +* // returns 1.0 +* +* var im = imagf( v ); +* // returns 2.0 +* +* v = y.data.get( 1 ); +* // returns +* +* re = realf( v ); +* // returns 5.0 +* +* im = imagf( v ); +* // returns 6.0 +*/ +function blockedmskfilter4d( x, mask, y ) { // eslint-disable-line max-statements + var bsize; + var xbuf; + var mbuf; + var ybuf; + var xget; + var mget; + var yset; + var dx0; + var dx1; + var dx2; + var dx3; + var dm0; + var dm1; + var dm2; + var dm3; + var dy0; + var ox1; + var ox2; + var ox3; + var om1; + var om2; + var om3; + var sh; + var s0; + var s1; + var s2; + var s3; + var sx; + var sm; + var ox; + var om; + var ix; + var im; + var iy; + var i0; + var i1; + var i2; + var i3; + var j0; + var j1; + var j2; + var j3; + var o; + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides, mask.strides ); + sh = o.sh; + sx = o.sx; + sm = o.sy; + + // Determine the block size: + bsize = blockSize( x.dtype, mask.dtype ); + + // Cache the indices of the first indexed elements in the respective ndarrays... + ox = x.offset; + om = mask.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + mbuf = mask.data; + ybuf = y.data; + + // Cache offset increments for the innermost loop... + dx0 = sx[0]; + dm0 = sm[0]; + dy0 = y.strides[0]; + + iy = y.offset; + + // Cache accessors: + xget = x.accessors[ 0 ]; + mget = mask.accessors[ 0 ]; + yset = y.accessors[ 1 ]; + + // Iterate over blocks... + for ( j3 = sh[3]; j3 > 0; ) { + if ( j3 < bsize ) { + s3 = j3; + j3 = 0; + } else { + s3 = bsize; + j3 -= bsize; + } + ox3 = ox + ( j3*sx[3] ); + om3 = om + ( j3*sm[3] ); + for ( j2 = sh[2]; j2 > 0; ) { + if ( j2 < bsize ) { + s2 = j2; + j2 = 0; + } else { + s2 = bsize; + j2 -= bsize; + } + dx3 = sx[3] - ( s2*sx[2] ); + dm3 = sm[3] - ( s2*sm[2] ); + ox2 = ox3 + ( j2*sx[2] ); + om2 = om3 + ( j2*sm[2] ); + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + dx2 = sx[2] - ( s1*sx[1] ); + dm2 = sm[2] - ( s1*sm[1] ); + ox1 = ox2 + ( j1*sx[1] ); + om1 = om2 + ( j1*sm[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute index offsets for the first input and output ndarray elements in the current block... + ix = ox1 + ( j0*sx[0] ); + im = om1 + ( j0*sm[0] ); + + // Compute loop offset increments... + dx1 = sx[1] - ( s0*sx[0] ); + dm1 = sm[1] - ( s0*sm[0] ); + + // Iterate over the ndarray dimensions... + for ( i3 = 0; i3 < s3; i3++ ) { + for ( i2 = 0; i2 < s2; i2++ ) { + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( mget( mbuf, im ) ) { + yset( ybuf, iy, xget( xbuf, ix ) ); + iy += dy0; + } + ix += dx0; + im += dm0; + } + ix += dx1; + im += dm1; + } + ix += dx2; + im += dm2; + } + ix += dx3; + im += dm3; + } + } + } + } + } +} + + +// EXPORTS // + +module.exports = blockedmskfilter4d; From f318edba1a521e3ba4b586cce2c73231ef7fa389 Mon Sep 17 00:00:00 2001 From: Jaysukh-409 Date: Mon, 5 Aug 2024 11:57:13 +0530 Subject: [PATCH 12/34] feat: add kernels for 5d ndarray --- .../@stdlib/ndarray/base/mskfilter/lib/5d.js | 195 ++++++++++++ .../base/mskfilter/lib/5d_accessors.js | 233 ++++++++++++++ .../ndarray/base/mskfilter/lib/5d_blocked.js | 260 +++++++++++++++ .../mskfilter/lib/5d_blocked_accessors.js | 298 ++++++++++++++++++ 4 files changed, 986 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_blocked.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_blocked_accessors.js diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d.js new file mode 100644 index 00000000000..b62ba398d3e --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d.js @@ -0,0 +1,195 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-depth */ + +'use strict'; + +// MAIN // + +/** +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {Object} mask - object containing mask ndarray meta data +* @param {Object} y - object containing output ndarray meta data +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Uint8Array = require( '@stdlib/array/uint8' ); +* +* // Define the shape of the array: +* var shape = [ 1, 1, 3, 1, 2 ]; +* +* // Define the array strides: +* var sx = [ 12, 12, 4, 4, 1 ]; +* var sm = [ 6, 6, 2, 2, 1 ]; +* var sy = [ 1 ]; +* +* // Define the index offset: +* var ox = 1; +* var om = 0; +* +* var x = { +* 'dtype': 'float64', +* 'data': 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 ] ), +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* var mask = { +* 'dtype': 'uint8', +* 'data': new Uint8Array( [ 1, 0, 1, 0, 1, 0 ] ), +* 'shape': shape, +* 'strides': sm, +* 'offset': om, +* 'order': 'row-major' +* }; +* +* var y = { +* 'dtype': 'float64', +* 'data': new Float64Array( 3 ), +* 'shape': [ 3 ], +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major' +* }; +* +* mskfilter5d( x, mask, y ); +* +* console.log( y.data ); +* // => [ 2.0, 6.0, 10.0 ] +*/ +function mskfilter5d( x, mask, y ) { + var xbuf; + var mbuf; + var ybuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dm0; + var dm1; + var dm2; + var dm3; + var dm4; + var dy0; + var S0; + var S1; + var S2; + var S3; + var S4; + var sh; + var sm; + var sx; + var ix; + var im; + var iy; + var i0; + var i1; + var i2; + var i3; + var i4; + + // Extract loop variables: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + sm = mask.strides; + if ( x.order === 'row-major' ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 4 ]; + S1 = sh[ 3 ]; + S2 = sh[ 2 ]; + S3 = sh[ 1 ]; + S4 = sh[ 0 ]; + dx0 = sx[ 4 ]; // offset increment for innermost loop + dx1 = sx[ 3 ] - ( S0*sx[4] ); + dx2 = sx[ 2 ] - ( S1*sx[3] ); + dx3 = sx[ 1 ] - ( S2*sx[2] ); + dx4 = sx[ 0 ] - ( S3*sx[1] ); // offset increment for outermost loop + dm0 = sm[ 4 ]; + dm1 = sm[ 3 ] - ( S0*sm[4] ); + dm2 = sm[ 2 ] - ( S1*sm[3] ); + dm3 = sm[ 1 ] - ( S2*sm[2] ); + dm4 = sm[ 0 ] - ( S3*sm[1] ); + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + S2 = sh[ 2 ]; + S3 = sh[ 3 ]; + S4 = sh[ 4 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); + dx2 = sx[ 2 ] - ( S1*sx[1] ); + dx3 = sx[ 3 ] - ( S2*sx[2] ); + dx4 = sx[ 4 ] - ( S3*sx[3] ); // offset increment for outermost loop + dm0 = sm[ 0 ]; + dm1 = sm[ 1 ] - ( S0*sm[0] ); + dm2 = sm[ 2 ] - ( S1*sm[1] ); + dm3 = sm[ 3 ] - ( S2*sm[2] ); + dm4 = sm[ 4 ] - ( S3*sm[3] ); + } + dy0 = y.strides[ 0 ]; + + // Set the pointers to the first indexed elements in the respective ndarrays... + ix = x.offset; + im = mask.offset; + iy = y.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + mbuf = mask.data; + ybuf = y.data; + + // Iterate over the ndarray dimensions... + for ( i4 = 0; i4 < S4; i4++ ) { + for ( i3 = 0; i3 < S3; i3++ ) { + for ( i2 = 0; i2 < S2; i2++ ) { + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( mbuf[ im ] ) { + ybuf[ iy ] = xbuf[ ix ]; + iy += dy0; + } + ix += dx0; + im += dm0; + } + ix += dx1; + im += dm1; + } + ix += dx2; + im += dm2; + } + ix += dx3; + im += dm3; + } + ix += dx4; + im += dm4; + } +} + + +// EXPORTS // + +module.exports = mskfilter5d; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_accessors.js new file mode 100644 index 00000000000..b08c27fec9f --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_accessors.js @@ -0,0 +1,233 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-depth */ + +'use strict'; + +// MAIN // + +/** +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {Object} mask - object containing mask ndarray meta data +* @param {Object} y - object containing output ndarray meta data +* @returns {void} +* +* @example +* var BooleanArray = require( '@stdlib/array/bool' ); +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* var realf = require( '@stdlib/complex/realf' ); +* var imagf = require( '@stdlib/complex/imagf' ); +* +* // Define the shape of the array: +* var shape = [ 1, 1, 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 2, 2, 2, 2, 1 ]; +* var sm = [ 2, 2, 2, 2, 1 ]; +* var sy = [ 1 ]; +* +* // Define the index offset: +* var ox = 0; +* var om = 0; +* +* // Define getters and setters: +* function getter( buf, idx ) { +* return buf.get( idx ); +* } +* +* function setter( buf, idx, value ) { +* buf.set( value, idx ); +* } +* +* var x = { +* 'dtype': 'complex64', +* 'data': new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ), +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* var mask = { +* 'dtype': 'bool', +* 'data': new BooleanArray( [ 1, 0, 1, 0 ] ), +* 'shape': shape, +* 'strides': sm, +* 'offset': om, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* var y = { +* 'dtype': 'complex64', +* 'data': new Complex64Array( 2 ), +* 'shape': [ 2 ], +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* mskfilter5d( x, mask, y ); +* +* var v = y.data.get( 0 ); +* // returns +* +* var re = realf( v ); +* // returns 1.0 +* +* var im = imagf( v ); +* // returns 2.0 +* +* v = y.data.get( 1 ); +* // returns +* +* re = realf( v ); +* // returns 5.0 +* +* im = imagf( v ); +* // returns 6.0 +*/ +function mskfilter5d( x, mask, y ) { + var xbuf; + var mbuf; + var ybuf; + var xget; + var mget; + var yset; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dm0; + var dm1; + var dm2; + var dm3; + var dm4; + var dy0; + var S0; + var S1; + var S2; + var S3; + var S4; + var sh; + var sm; + var sx; + var ix; + var im; + var iy; + var i0; + var i1; + var i2; + var i3; + var i4; + + // Extract loop variables: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + sm = mask.strides; + if ( x.order === 'row-major' ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 4 ]; + S1 = sh[ 3 ]; + S2 = sh[ 2 ]; + S3 = sh[ 1 ]; + S4 = sh[ 0 ]; + dx0 = sx[ 4 ]; // offset increment for innermost loop + dx1 = sx[ 3 ] - ( S0*sx[4] ); + dx2 = sx[ 2 ] - ( S1*sx[3] ); + dx3 = sx[ 1 ] - ( S2*sx[2] ); + dx4 = sx[ 0 ] - ( S3*sx[1] ); // offset increment for outermost loop + dm0 = sm[ 4 ]; + dm1 = sm[ 3 ] - ( S0*sm[4] ); + dm2 = sm[ 2 ] - ( S1*sm[3] ); + dm3 = sm[ 1 ] - ( S2*sm[2] ); + dm4 = sm[ 0 ] - ( S3*sm[1] ); + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + S2 = sh[ 2 ]; + S3 = sh[ 3 ]; + S4 = sh[ 4 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); + dx2 = sx[ 2 ] - ( S1*sx[1] ); + dx3 = sx[ 3 ] - ( S2*sx[2] ); + dx4 = sx[ 4 ] - ( S3*sx[3] ); // offset increment for outermost loop + dm0 = sm[ 0 ]; + dm1 = sm[ 1 ] - ( S0*sm[0] ); + dm2 = sm[ 2 ] - ( S1*sm[1] ); + dm3 = sm[ 3 ] - ( S2*sm[2] ); + dm4 = sm[ 4 ] - ( S3*sm[3] ); + } + dy0 = y.strides[ 0 ]; + + // Set the pointers to the first indexed elements in the respective ndarrays... + ix = x.offset; + im = mask.offset; + iy = y.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + mbuf = mask.data; + ybuf = y.data; + + // Cache accessors: + xget = x.accessors[ 0 ]; + mget = mask.accessors[ 0 ]; + yset = y.accessors[ 1 ]; + + // Iterate over the ndarray dimensions... + for ( i4 = 0; i4 < S4; i4++ ) { + for ( i3 = 0; i3 < S3; i3++ ) { + for ( i2 = 0; i2 < S2; i2++ ) { + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( mget( mbuf, im ) ) { + yset( ybuf, iy, xget( xbuf, ix ) ); + iy += dy0; + } + ix += dx0; + im += dm0; + } + ix += dx1; + im += dm1; + } + ix += dx2; + im += dm2; + } + ix += dx3; + im += dm3; + } + ix += dx4; + im += dm4; + } +} + + +// EXPORTS // + +module.exports = mskfilter5d; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_blocked.js new file mode 100644 index 00000000000..fe9c99e4edb --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_blocked.js @@ -0,0 +1,260 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-depth */ + +'use strict'; + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/unary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); + + +// MAIN // + +/** +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {Object} mask - object containing mask ndarray meta data +* @param {Object} y - object containing output ndarray meta data +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Uint8Array = require( '@stdlib/array/uint8' ); +* +* // Define the shape of the array: +* var shape = [ 1, 1, 3, 1, 2 ]; +* +* // Define the array strides: +* var sx = [ 12, 12, 4, 4, 1 ]; +* var sm = [ 6, 6, 2, 2, 1 ]; +* var sy = [ 1 ]; +* +* // Define the index offset: +* var ox = 1; +* var om = 0; +* +* var x = { +* 'dtype': 'float64', +* 'data': 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 ] ), +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* var mask = { +* 'dtype': 'uint8', +* 'data': new Uint8Array( [ 1, 0, 1, 0, 1, 0 ] ), +* 'shape': shape, +* 'strides': sm, +* 'offset': om, +* 'order': 'row-major' +* }; +* +* var y = { +* 'dtype': 'float64', +* 'data': new Float64Array( 3 ), +* 'shape': [ 3 ], +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major' +* }; +* +* blockedmskfilter5d( x, mask, y ); +* +* console.log( y.data ); +* // => [ 2.0, 6.0, 10.0 ] +*/ +function blockedmskfilter5d( x, mask, y ) { // eslint-disable-line max-statements + var bsize; + var xbuf; + var mbuf; + var ybuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dm0; + var dm1; + var dm2; + var dm3; + var dm4; + var dy0; + var ox1; + var ox2; + var ox3; + var ox4; + var om1; + var om2; + var om3; + var om4; + var sh; + var s0; + var s1; + var s2; + var s3; + var s4; + var sx; + var sm; + var ox; + var om; + var ix; + var im; + var iy; + var i0; + var i1; + var i2; + var i3; + var i4; + var j0; + var j1; + var j2; + var j3; + var j4; + var o; + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides, mask.strides ); + sh = o.sh; + sx = o.sx; + sm = o.sy; + + // Determine the block size: + bsize = blockSize( x.dtype, mask.dtype ); + + // Cache the indices of the first indexed elements in the respective ndarrays... + ox = x.offset; + om = mask.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + mbuf = mask.data; + ybuf = y.data; + + // Cache offset increments for the innermost loop... + dx0 = sx[0]; + dm0 = sm[0]; + dy0 = y.strides[0]; + + iy = y.offset; + + // Iterate over blocks... + for ( j4 = sh[4]; j4 > 0; ) { + if ( j4 < bsize ) { + s4 = j4; + j4 = 0; + } else { + s4 = bsize; + j4 -= bsize; + } + ox4 = ox + ( j4*sx[4] ); + om4 = om + ( j4*sm[4] ); + for ( j3 = sh[3]; j3 > 0; ) { + if ( j3 < bsize ) { + s3 = j3; + j3 = 0; + } else { + s3 = bsize; + j3 -= bsize; + } + dx4 = sx[4] - ( s3*sx[3] ); + dm4 = sm[4] - ( s3*sm[3] ); + ox3 = ox4 + ( j3*sx[3] ); + om3 = om4 + ( j3*sm[3] ); + for ( j2 = sh[2]; j2 > 0; ) { + if ( j2 < bsize ) { + s2 = j2; + j2 = 0; + } else { + s2 = bsize; + j2 -= bsize; + } + dx3 = sx[3] - ( s2*sx[2] ); + dm3 = sm[3] - ( s2*sm[2] ); + ox2 = ox3 + ( j2*sx[2] ); + om2 = om3 + ( j2*sm[2] ); + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + dx2 = sx[2] - ( s1*sx[1] ); + dm2 = sm[2] - ( s1*sm[1] ); + ox1 = ox2 + ( j1*sx[1] ); + om1 = om2 + ( j1*sm[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute index offsets for the first input and output ndarray elements in the current block... + ix = ox1 + ( j0*sx[0] ); + im = om1 + ( j0*sm[0] ); + + // Compute loop offset increments... + dx1 = sx[1] - ( s0*sx[0] ); + dm1 = sm[1] - ( s0*sm[0] ); + + // Iterate over the ndarray dimensions... + for ( i4 = 0; i4 < s4; i4++ ) { + for ( i3 = 0; i3 < s3; i3++ ) { + for ( i2 = 0; i2 < s2; i2++ ) { + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( mbuf[ im ] ) { + ybuf[ iy ] = xbuf[ ix ]; + iy += dy0; + } + ix += dx0; + im += dm0; + } + ix += dx1; + im += dm1; + } + ix += dx2; + im += dm2; + } + ix += dx3; + im += dm3; + } + ix += dx4; + im += dm4; + } + } + } + } + } + } +} + + +// EXPORTS // + +module.exports = blockedmskfilter5d; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_blocked_accessors.js new file mode 100644 index 00000000000..bd7d0b35183 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_blocked_accessors.js @@ -0,0 +1,298 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-depth */ + +'use strict'; + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/unary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); + + +// MAIN // + +/** +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {Object} mask - object containing mask ndarray meta data +* @param {Object} y - object containing output ndarray meta data +* @returns {void} +* +* @example +* var BooleanArray = require( '@stdlib/array/bool' ); +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* var realf = require( '@stdlib/complex/realf' ); +* var imagf = require( '@stdlib/complex/imagf' ); +* +* // Define the shape of the array: +* var shape = [ 1, 1, 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 2, 2, 2, 2, 1 ]; +* var sm = [ 2, 2, 2, 2, 1 ]; +* var sy = [ 1 ]; +* +* // Define the index offset: +* var ox = 0; +* var om = 0; +* +* // Define getters and setters: +* function getter( buf, idx ) { +* return buf.get( idx ); +* } +* +* function setter( buf, idx, value ) { +* buf.set( value, idx ); +* } +* +* var x = { +* 'dtype': 'complex64', +* 'data': new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ), +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* var mask = { +* 'dtype': 'bool', +* 'data': new BooleanArray( [ 1, 0, 1, 0 ] ), +* 'shape': shape, +* 'strides': sm, +* 'offset': om, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* var y = { +* 'dtype': 'complex64', +* 'data': new Complex64Array( 2 ), +* 'shape': [ 2 ], +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* blockedmskfilter5d( x, mask, y ); +* +* var v = y.data.get( 0 ); +* // returns +* +* var re = realf( v ); +* // returns 1.0 +* +* var im = imagf( v ); +* // returns 2.0 +* +* v = y.data.get( 1 ); +* // returns +* +* re = realf( v ); +* // returns 5.0 +* +* im = imagf( v ); +* // returns 6.0 +*/ +function blockedmskfilter5d( x, mask, y ) { // eslint-disable-line max-statements + var bsize; + var xbuf; + var mbuf; + var ybuf; + var xget; + var mget; + var yset; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dm0; + var dm1; + var dm2; + var dm3; + var dm4; + var dy0; + var ox1; + var ox2; + var ox3; + var ox4; + var om1; + var om2; + var om3; + var om4; + var sh; + var s0; + var s1; + var s2; + var s3; + var s4; + var sx; + var sm; + var ox; + var om; + var ix; + var im; + var iy; + var i0; + var i1; + var i2; + var i3; + var i4; + var j0; + var j1; + var j2; + var j3; + var j4; + var o; + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides, mask.strides ); + sh = o.sh; + sx = o.sx; + sm = o.sy; + + // Determine the block size: + bsize = blockSize( x.dtype, mask.dtype ); + + // Cache the indices of the first indexed elements in the respective ndarrays... + ox = x.offset; + om = mask.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + mbuf = mask.data; + ybuf = y.data; + + // Cache offset increments for the innermost loop... + dx0 = sx[0]; + dm0 = sm[0]; + dy0 = y.strides[0]; + + iy = y.offset; + + // Cache accessors: + xget = x.accessors[ 0 ]; + mget = mask.accessors[ 0 ]; + yset = y.accessors[ 1 ]; + + // Iterate over blocks... + for ( j4 = sh[4]; j4 > 0; ) { + if ( j4 < bsize ) { + s4 = j4; + j4 = 0; + } else { + s4 = bsize; + j4 -= bsize; + } + ox4 = ox + ( j4*sx[4] ); + om4 = om + ( j4*sm[4] ); + for ( j3 = sh[3]; j3 > 0; ) { + if ( j3 < bsize ) { + s3 = j3; + j3 = 0; + } else { + s3 = bsize; + j3 -= bsize; + } + dx4 = sx[4] - ( s3*sx[3] ); + dm4 = sm[4] - ( s3*sm[3] ); + ox3 = ox4 + ( j3*sx[3] ); + om3 = om4 + ( j3*sm[3] ); + for ( j2 = sh[2]; j2 > 0; ) { + if ( j2 < bsize ) { + s2 = j2; + j2 = 0; + } else { + s2 = bsize; + j2 -= bsize; + } + dx3 = sx[3] - ( s2*sx[2] ); + dm3 = sm[3] - ( s2*sm[2] ); + ox2 = ox3 + ( j2*sx[2] ); + om2 = om3 + ( j2*sm[2] ); + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + dx2 = sx[2] - ( s1*sx[1] ); + dm2 = sm[2] - ( s1*sm[1] ); + ox1 = ox2 + ( j1*sx[1] ); + om1 = om2 + ( j1*sm[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute index offsets for the first input and output ndarray elements in the current block... + ix = ox1 + ( j0*sx[0] ); + im = om1 + ( j0*sm[0] ); + + // Compute loop offset increments... + dx1 = sx[1] - ( s0*sx[0] ); + dm1 = sm[1] - ( s0*sm[0] ); + + // Iterate over the ndarray dimensions... + for ( i4 = 0; i4 < s4; i4++ ) { + for ( i3 = 0; i3 < s3; i3++ ) { + for ( i2 = 0; i2 < s2; i2++ ) { + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( mget( mbuf, im ) ) { + yset( ybuf, iy, xget( xbuf, ix ) ); + iy += dy0; + } + ix += dx0; + im += dm0; + } + ix += dx1; + im += dm1; + } + ix += dx2; + im += dm2; + } + ix += dx3; + im += dm3; + } + ix += dx4; + im += dm4; + } + } + } + } + } + } +} + + +// EXPORTS // + +module.exports = blockedmskfilter5d; From 7235a972b558dd1dc49366c0fa6aea3bd88517d8 Mon Sep 17 00:00:00 2001 From: Jaysukh-409 Date: Mon, 5 Aug 2024 16:07:10 +0530 Subject: [PATCH 13/34] feat: add kernels for 6d ndarray --- .../@stdlib/ndarray/base/mskfilter/lib/6d.js | 209 ++++++++++++ .../base/mskfilter/lib/6d_accessors.js | 247 ++++++++++++++ .../ndarray/base/mskfilter/lib/6d_blocked.js | 284 +++++++++++++++ .../mskfilter/lib/6d_blocked_accessors.js | 322 ++++++++++++++++++ 4 files changed, 1062 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_blocked.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_blocked_accessors.js diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d.js new file mode 100644 index 00000000000..d2f316857fe --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d.js @@ -0,0 +1,209 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-depth */ + +'use strict'; + +// MAIN // + +/** +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {Object} mask - object containing mask ndarray meta data +* @param {Object} y - object containing output ndarray meta data +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Uint8Array = require( '@stdlib/array/uint8' ); +* +* // Define the shape of the array: +* var shape = [ 1, 1, 1, 3, 1, 2 ]; +* +* // Define the array strides: +* var sx = [ 12, 12, 12, 4, 4, 1 ]; +* var sm = [ 6, 6, 6, 2, 2, 1 ]; +* var sy = [ 1 ]; +* +* // Define the index offset: +* var ox = 1; +* var om = 0; +* +* var x = { +* 'dtype': 'float64', +* 'data': 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 ] ), +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* var mask = { +* 'dtype': 'uint8', +* 'data': new Uint8Array( [ 1, 0, 1, 0, 1, 0 ] ), +* 'shape': shape, +* 'strides': sm, +* 'offset': om, +* 'order': 'row-major' +* }; +* +* var y = { +* 'dtype': 'float64', +* 'data': new Float64Array( 3 ), +* 'shape': [ 3 ], +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major' +* }; +* +* mskfilter6d( x, mask, y ); +* +* console.log( y.data ); +* // => [ 2.0, 6.0, 10.0 ] +*/ +function mskfilter6d( x, mask, y ) { // eslint-disable-line max-statements + var xbuf; + var mbuf; + var ybuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dm0; + var dm1; + var dm2; + var dm3; + var dm4; + var dm5; + var dy0; + var S0; + var S1; + var S2; + var S3; + var S4; + var S5; + var sh; + var sm; + var sx; + var ix; + var im; + var iy; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + + // Extract loop variables: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + sm = mask.strides; + if ( x.order === 'row-major' ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 5 ]; + S1 = sh[ 4 ]; + S2 = sh[ 3 ]; + S3 = sh[ 2 ]; + S4 = sh[ 1 ]; + S5 = sh[ 0 ]; + dx0 = sx[ 5 ]; // offset increment for innermost loop + dx1 = sx[ 4 ] - ( S0*sx[5] ); + dx2 = sx[ 3 ] - ( S1*sx[4] ); + dx3 = sx[ 2 ] - ( S2*sx[3] ); + dx4 = sx[ 1 ] - ( S3*sx[2] ); + dx5 = sx[ 0 ] - ( S4*sx[1] ); // offset increment for outermost loop + dm0 = sm[ 5 ]; + dm1 = sm[ 4 ] - ( S0*sm[5] ); + dm2 = sm[ 3 ] - ( S1*sm[4] ); + dm3 = sm[ 2 ] - ( S2*sm[3] ); + dm4 = sm[ 1 ] - ( S3*sm[2] ); + dm5 = sm[ 0 ] - ( S4*sm[1] ); + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + S2 = sh[ 2 ]; + S3 = sh[ 3 ]; + S4 = sh[ 4 ]; + S5 = sh[ 5 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); + dx2 = sx[ 2 ] - ( S1*sx[1] ); + dx3 = sx[ 3 ] - ( S2*sx[2] ); + dx4 = sx[ 4 ] - ( S3*sx[3] ); + dx5 = sx[ 5 ] - ( S4*sx[4] ); // offset increment for outermost loop + dm0 = sm[ 0 ]; + dm1 = sm[ 1 ] - ( S0*sm[0] ); + dm2 = sm[ 2 ] - ( S1*sm[1] ); + dm3 = sm[ 3 ] - ( S2*sm[2] ); + dm4 = sm[ 4 ] - ( S3*sm[3] ); + dm5 = sm[ 5 ] - ( S4*sm[4] ); + } + dy0 = y.strides[ 0 ]; + + // Set the pointers to the first indexed elements in the respective ndarrays... + ix = x.offset; + im = mask.offset; + iy = y.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + mbuf = mask.data; + ybuf = y.data; + + // Iterate over the ndarray dimensions... + for ( i5 = 0; i5 < S5; i5++ ) { + for ( i4 = 0; i4 < S4; i4++ ) { + for ( i3 = 0; i3 < S3; i3++ ) { + for ( i2 = 0; i2 < S2; i2++ ) { + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( mbuf[ im ] ) { + ybuf[ iy ] = xbuf[ ix ]; + iy += dy0; + } + ix += dx0; + im += dm0; + } + ix += dx1; + im += dm1; + } + ix += dx2; + im += dm2; + } + ix += dx3; + im += dm3; + } + ix += dx4; + im += dm4; + } + ix += dx5; + im += dm5; + } +} + + +// EXPORTS // + +module.exports = mskfilter6d; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_accessors.js new file mode 100644 index 00000000000..e515820726f --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_accessors.js @@ -0,0 +1,247 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-depth */ + +'use strict'; + +// MAIN // + +/** +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {Object} mask - object containing mask ndarray meta data +* @param {Object} y - object containing output ndarray meta data +* @returns {void} +* +* @example +* var BooleanArray = require( '@stdlib/array/bool' ); +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* var realf = require( '@stdlib/complex/realf' ); +* var imagf = require( '@stdlib/complex/imagf' ); +* +* // Define the shape of the array: +* var shape = [ 1, 1, 1, 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 2, 2, 2, 2, 2, 1 ]; +* var sm = [ 2, 2, 2, 2, 2, 1 ]; +* var sy = [ 1 ]; +* +* // Define the index offset: +* var ox = 0; +* var om = 0; +* +* // Define getters and setters: +* function getter( buf, idx ) { +* return buf.get( idx ); +* } +* +* function setter( buf, idx, value ) { +* buf.set( value, idx ); +* } +* +* var x = { +* 'dtype': 'complex64', +* 'data': new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ), +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* var mask = { +* 'dtype': 'bool', +* 'data': new BooleanArray( [ 1, 0, 1, 0 ] ), +* 'shape': shape, +* 'strides': sm, +* 'offset': om, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* var y = { +* 'dtype': 'complex64', +* 'data': new Complex64Array( 2 ), +* 'shape': [ 2 ], +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* mskfilter6d( x, mask, y ); +* +* var v = y.data.get( 0 ); +* // returns +* +* var re = realf( v ); +* // returns 1.0 +* +* var im = imagf( v ); +* // returns 2.0 +* +* v = y.data.get( 1 ); +* // returns +* +* re = realf( v ); +* // returns 5.0 +* +* im = imagf( v ); +* // returns 6.0 +*/ +function mskfilter6d( x, mask, y ) { // eslint-disable-line max-statements + var xbuf; + var mbuf; + var ybuf; + var xget; + var mget; + var yset; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dm0; + var dm1; + var dm2; + var dm3; + var dm4; + var dm5; + var dy0; + var S0; + var S1; + var S2; + var S3; + var S4; + var S5; + var sh; + var sm; + var sx; + var ix; + var im; + var iy; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + + // Extract loop variables: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + sm = mask.strides; + if ( x.order === 'row-major' ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 5 ]; + S1 = sh[ 4 ]; + S2 = sh[ 3 ]; + S3 = sh[ 2 ]; + S4 = sh[ 1 ]; + S5 = sh[ 0 ]; + dx0 = sx[ 5 ]; // offset increment for innermost loop + dx1 = sx[ 4 ] - ( S0*sx[5] ); + dx2 = sx[ 3 ] - ( S1*sx[4] ); + dx3 = sx[ 2 ] - ( S2*sx[3] ); + dx4 = sx[ 1 ] - ( S3*sx[2] ); + dx5 = sx[ 0 ] - ( S4*sx[1] ); // offset increment for outermost loop + dm0 = sm[ 5 ]; + dm1 = sm[ 4 ] - ( S0*sm[5] ); + dm2 = sm[ 3 ] - ( S1*sm[4] ); + dm3 = sm[ 2 ] - ( S2*sm[3] ); + dm4 = sm[ 1 ] - ( S3*sm[2] ); + dm5 = sm[ 0 ] - ( S4*sm[1] ); + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + S2 = sh[ 2 ]; + S3 = sh[ 3 ]; + S4 = sh[ 4 ]; + S5 = sh[ 5 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); + dx2 = sx[ 2 ] - ( S1*sx[1] ); + dx3 = sx[ 3 ] - ( S2*sx[2] ); + dx4 = sx[ 4 ] - ( S3*sx[3] ); + dx5 = sx[ 5 ] - ( S4*sx[4] ); // offset increment for outermost loop + dm0 = sm[ 0 ]; + dm1 = sm[ 1 ] - ( S0*sm[0] ); + dm2 = sm[ 2 ] - ( S1*sm[1] ); + dm3 = sm[ 3 ] - ( S2*sm[2] ); + dm4 = sm[ 4 ] - ( S3*sm[3] ); + dm5 = sm[ 5 ] - ( S4*sm[4] ); + } + dy0 = y.strides[ 0 ]; + + // Set the pointers to the first indexed elements in the respective ndarrays... + ix = x.offset; + im = mask.offset; + iy = y.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + mbuf = mask.data; + ybuf = y.data; + + // Cache accessors: + xget = x.accessors[ 0 ]; + mget = mask.accessors[ 0 ]; + yset = y.accessors[ 1 ]; + + // Iterate over the ndarray dimensions... + for ( i5 = 0; i5 < S5; i5++ ) { + for ( i4 = 0; i4 < S4; i4++ ) { + for ( i3 = 0; i3 < S3; i3++ ) { + for ( i2 = 0; i2 < S2; i2++ ) { + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( mget( mbuf, im ) ) { + yset( ybuf, iy, xget( xbuf, ix ) ); + iy += dy0; + } + ix += dx0; + im += dm0; + } + ix += dx1; + im += dm1; + } + ix += dx2; + im += dm2; + } + ix += dx3; + im += dm3; + } + ix += dx4; + im += dm4; + } + ix += dx5; + im += dm5; + } +} + + +// EXPORTS // + +module.exports = mskfilter6d; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_blocked.js new file mode 100644 index 00000000000..fe06f9d8cfe --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_blocked.js @@ -0,0 +1,284 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-depth */ + +'use strict'; + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/unary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); + + +// MAIN // + +/** +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {Object} mask - object containing mask ndarray meta data +* @param {Object} y - object containing output ndarray meta data +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Uint8Array = require( '@stdlib/array/uint8' ); +* +* // Define the shape of the array: +* var shape = [ 1, 1, 1, 3, 1, 2 ]; +* +* // Define the array strides: +* var sx = [ 12, 12, 12, 4, 4, 1 ]; +* var sm = [ 6, 6, 6, 2, 2, 1 ]; +* var sy = [ 1 ]; +* +* // Define the index offset: +* var ox = 1; +* var om = 0; +* +* var x = { +* 'dtype': 'float64', +* 'data': 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 ] ), +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* var mask = { +* 'dtype': 'uint8', +* 'data': new Uint8Array( [ 1, 0, 1, 0, 1, 0 ] ), +* 'shape': shape, +* 'strides': sm, +* 'offset': om, +* 'order': 'row-major' +* }; +* +* var y = { +* 'dtype': 'float64', +* 'data': new Float64Array( 3 ), +* 'shape': [ 3 ], +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major' +* }; +* +* blockedmskfilter6d( x, mask, y ); +* +* console.log( y.data ); +* // => [ 2.0, 6.0, 10.0 ] +*/ +function blockedmskfilter6d( x, mask, y ) { // eslint-disable-line max-statements + var bsize; + var xbuf; + var mbuf; + var ybuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dm0; + var dm1; + var dm2; + var dm3; + var dm4; + var dm5; + var dy0; + var ox1; + var ox2; + var ox3; + var ox4; + var ox5; + var om1; + var om2; + var om3; + var om4; + var om5; + var sh; + var s0; + var s1; + var s2; + var s3; + var s4; + var s5; + var sx; + var sm; + var ox; + var om; + var ix; + var im; + var iy; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var j0; + var j1; + var j2; + var j3; + var j4; + var j5; + var o; + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides, mask.strides ); + sh = o.sh; + sx = o.sx; + sm = o.sy; + + // Determine the block size: + bsize = blockSize( x.dtype, mask.dtype ); + + // Cache the indices of the first indexed elements in the respective ndarrays... + ox = x.offset; + om = mask.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + mbuf = mask.data; + ybuf = y.data; + + // Cache offset increments for the innermost loop... + dx0 = sx[0]; + dm0 = sm[0]; + dy0 = y.strides[0]; + + iy = y.offset; + + // Iterate over blocks... + for ( j5 = sh[5]; j5 > 0; ) { + if ( j5 < bsize ) { + s5 = j5; + j5 = 0; + } else { + s5 = bsize; + j5 -= bsize; + } + ox5 = ox + ( j5*sx[5] ); + om5 = om + ( j5*sm[5] ); + for ( j4 = sh[4]; j4 > 0; ) { + if ( j4 < bsize ) { + s4 = j4; + j4 = 0; + } else { + s4 = bsize; + j4 -= bsize; + } + dx5 = sx[5] - ( s4*sx[4] ); + dm5 = sm[5] - ( s4*sm[4] ); + ox4 = ox5 + ( j4*sx[4] ); + om4 = om5 + ( j4*sm[4] ); + for ( j3 = sh[3]; j3 > 0; ) { + if ( j3 < bsize ) { + s3 = j3; + j3 = 0; + } else { + s3 = bsize; + j3 -= bsize; + } + dx4 = sx[4] - ( s3*sx[3] ); + dm4 = sm[4] - ( s3*sm[3] ); + ox3 = ox4 + ( j3*sx[3] ); + om3 = om4 + ( j3*sm[3] ); + for ( j2 = sh[2]; j2 > 0; ) { + if ( j2 < bsize ) { + s2 = j2; + j2 = 0; + } else { + s2 = bsize; + j2 -= bsize; + } + dx3 = sx[3] - ( s2*sx[2] ); + dm3 = sm[3] - ( s2*sm[2] ); + ox2 = ox3 + ( j2*sx[2] ); + om2 = om3 + ( j2*sm[2] ); + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + dx2 = sx[2] - ( s1*sx[1] ); + dm2 = sm[2] - ( s1*sm[1] ); + ox1 = ox2 + ( j1*sx[1] ); + om1 = om2 + ( j1*sm[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute index offsets for the first input and output ndarray elements in the current block... + ix = ox1 + ( j0*sx[0] ); + im = om1 + ( j0*sm[0] ); + + // Compute loop offset increments... + dx1 = sx[1] - ( s0*sx[0] ); + dm1 = sm[1] - ( s0*sm[0] ); + + // Iterate over the ndarray dimensions... + for ( i5 = 0; i5 < s5; i5++ ) { + for ( i4 = 0; i4 < s4; i4++ ) { + for ( i3 = 0; i3 < s3; i3++ ) { + for ( i2 = 0; i2 < s2; i2++ ) { + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( mbuf[ im ] ) { + ybuf[ iy ] = xbuf[ ix ]; + iy += dy0; + } + ix += dx0; + im += dm0; + } + ix += dx1; + im += dm1; + } + ix += dx2; + im += dm2; + } + ix += dx3; + im += dm3; + } + ix += dx4; + im += dm4; + } + ix += dx5; + im += dm5; + } + } + } + } + } + } + } +} + + +// EXPORTS // + +module.exports = blockedmskfilter6d; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_blocked_accessors.js new file mode 100644 index 00000000000..bdd1a772c4d --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_blocked_accessors.js @@ -0,0 +1,322 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-depth */ + +'use strict'; + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/unary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); + + +// MAIN // + +/** +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {Object} mask - object containing mask ndarray meta data +* @param {Object} y - object containing output ndarray meta data +* @returns {void} +* +* @example +* var BooleanArray = require( '@stdlib/array/bool' ); +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* var realf = require( '@stdlib/complex/realf' ); +* var imagf = require( '@stdlib/complex/imagf' ); +* +* // Define the shape of the array: +* var shape = [ 1, 1, 1, 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 2, 2, 2, 2, 2, 1 ]; +* var sm = [ 2, 2, 2, 2, 2, 1 ]; +* var sy = [ 1 ]; +* +* // Define the index offset: +* var ox = 0; +* var om = 0; +* +* // Define getters and setters: +* function getter( buf, idx ) { +* return buf.get( idx ); +* } +* +* function setter( buf, idx, value ) { +* buf.set( value, idx ); +* } +* +* var x = { +* 'dtype': 'complex64', +* 'data': new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ), +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* var mask = { +* 'dtype': 'bool', +* 'data': new BooleanArray( [ 1, 0, 1, 0 ] ), +* 'shape': shape, +* 'strides': sm, +* 'offset': om, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* var y = { +* 'dtype': 'complex64', +* 'data': new Complex64Array( 2 ), +* 'shape': [ 2 ], +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* blockedmskfilter6d( x, mask, y ); +* +* var v = y.data.get( 0 ); +* // returns +* +* var re = realf( v ); +* // returns 1.0 +* +* var im = imagf( v ); +* // returns 2.0 +* +* v = y.data.get( 1 ); +* // returns +* +* re = realf( v ); +* // returns 5.0 +* +* im = imagf( v ); +* // returns 6.0 +*/ +function blockedmskfilter6d( x, mask, y ) { // eslint-disable-line max-statements + var bsize; + var xbuf; + var mbuf; + var ybuf; + var xget; + var mget; + var yset; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dm0; + var dm1; + var dm2; + var dm3; + var dm4; + var dm5; + var dy0; + var ox1; + var ox2; + var ox3; + var ox4; + var ox5; + var om1; + var om2; + var om3; + var om4; + var om5; + var sh; + var s0; + var s1; + var s2; + var s3; + var s4; + var s5; + var sx; + var sm; + var ox; + var om; + var ix; + var im; + var iy; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var j0; + var j1; + var j2; + var j3; + var j4; + var j5; + var o; + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides, mask.strides ); + sh = o.sh; + sx = o.sx; + sm = o.sy; + + // Determine the block size: + bsize = blockSize( x.dtype, mask.dtype ); + + // Cache the indices of the first indexed elements in the respective ndarrays... + ox = x.offset; + om = mask.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + mbuf = mask.data; + ybuf = y.data; + + // Cache offset increments for the innermost loop... + dx0 = sx[0]; + dm0 = sm[0]; + dy0 = y.strides[0]; + + iy = y.offset; + + // Cache accessors: + xget = x.accessors[ 0 ]; + mget = mask.accessors[ 0 ]; + yset = y.accessors[ 1 ]; + + // Iterate over blocks... + for ( j5 = sh[5]; j5 > 0; ) { + if ( j5 < bsize ) { + s5 = j5; + j5 = 0; + } else { + s5 = bsize; + j5 -= bsize; + } + ox5 = ox + ( j5*sx[5] ); + om5 = om + ( j5*sm[5] ); + for ( j4 = sh[4]; j4 > 0; ) { + if ( j4 < bsize ) { + s4 = j4; + j4 = 0; + } else { + s4 = bsize; + j4 -= bsize; + } + dx5 = sx[5] - ( s4*sx[4] ); + dm5 = sm[5] - ( s4*sm[4] ); + ox4 = ox5 + ( j4*sx[4] ); + om4 = om5 + ( j4*sm[4] ); + for ( j3 = sh[3]; j3 > 0; ) { + if ( j3 < bsize ) { + s3 = j3; + j3 = 0; + } else { + s3 = bsize; + j3 -= bsize; + } + dx4 = sx[4] - ( s3*sx[3] ); + dm4 = sm[4] - ( s3*sm[3] ); + ox3 = ox4 + ( j3*sx[3] ); + om3 = om4 + ( j3*sm[3] ); + for ( j2 = sh[2]; j2 > 0; ) { + if ( j2 < bsize ) { + s2 = j2; + j2 = 0; + } else { + s2 = bsize; + j2 -= bsize; + } + dx3 = sx[3] - ( s2*sx[2] ); + dm3 = sm[3] - ( s2*sm[2] ); + ox2 = ox3 + ( j2*sx[2] ); + om2 = om3 + ( j2*sm[2] ); + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + dx2 = sx[2] - ( s1*sx[1] ); + dm2 = sm[2] - ( s1*sm[1] ); + ox1 = ox2 + ( j1*sx[1] ); + om1 = om2 + ( j1*sm[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute index offsets for the first input and output ndarray elements in the current block... + ix = ox1 + ( j0*sx[0] ); + im = om1 + ( j0*sm[0] ); + + // Compute loop offset increments... + dx1 = sx[1] - ( s0*sx[0] ); + dm1 = sm[1] - ( s0*sm[0] ); + + // Iterate over the ndarray dimensions... + for ( i5 = 0; i5 < s5; i5++ ) { + for ( i4 = 0; i4 < s4; i4++ ) { + for ( i3 = 0; i3 < s3; i3++ ) { + for ( i2 = 0; i2 < s2; i2++ ) { + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( mget( mbuf, im ) ) { + yset( ybuf, iy, xget( xbuf, ix ) ); + iy += dy0; + } + ix += dx0; + im += dm0; + } + ix += dx1; + im += dm1; + } + ix += dx2; + im += dm2; + } + ix += dx3; + im += dm3; + } + ix += dx4; + im += dm4; + } + ix += dx5; + im += dm5; + } + } + } + } + } + } + } +} + + +// EXPORTS // + +module.exports = blockedmskfilter6d; From d7683e0268d6bab5c38ee6cc8f086b30ac3ae189 Mon Sep 17 00:00:00 2001 From: Jaysukh-409 Date: Mon, 5 Aug 2024 16:32:51 +0530 Subject: [PATCH 14/34] feat: add kernels for 7d ndarray --- .../@stdlib/ndarray/base/mskfilter/lib/7d.js | 223 +++++++++++ .../base/mskfilter/lib/7d_accessors.js | 261 +++++++++++++ .../ndarray/base/mskfilter/lib/7d_blocked.js | 308 ++++++++++++++++ .../mskfilter/lib/7d_blocked_accessors.js | 346 ++++++++++++++++++ 4 files changed, 1138 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_blocked.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_blocked_accessors.js diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d.js new file mode 100644 index 00000000000..d592a1649a0 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d.js @@ -0,0 +1,223 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-depth */ + +'use strict'; + +// MAIN // + +/** +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {Object} mask - object containing mask ndarray meta data +* @param {Object} y - object containing output ndarray meta data +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Uint8Array = require( '@stdlib/array/uint8' ); +* +* // Define the shape of the array: +* var shape = [ 1, 1, 1, 1, 3, 1, 2 ]; +* +* // Define the array strides: +* var sx = [ 12, 12, 12, 12, 4, 4, 1 ]; +* var sm = [ 6, 6, 6, 6, 2, 2, 1 ]; +* var sy = [ 1 ]; +* +* // Define the index offset: +* var ox = 1; +* var om = 0; +* +* var x = { +* 'dtype': 'float64', +* 'data': 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 ] ), +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* var mask = { +* 'dtype': 'uint8', +* 'data': new Uint8Array( [ 1, 0, 1, 0, 1, 0 ] ), +* 'shape': shape, +* 'strides': sm, +* 'offset': om, +* 'order': 'row-major' +* }; +* +* var y = { +* 'dtype': 'float64', +* 'data': new Float64Array( 3 ), +* 'shape': [ 3 ], +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major' +* }; +* +* mskfilter7d( x, mask, y ); +* +* console.log( y.data ); +* // => [ 2.0, 6.0, 10.0 ] +*/ +function mskfilter7d( x, mask, y ) { // eslint-disable-line max-statements + var xbuf; + var mbuf; + var ybuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dx6; + var dm0; + var dm1; + var dm2; + var dm3; + var dm4; + var dm5; + var dm6; + var dy0; + var S0; + var S1; + var S2; + var S3; + var S4; + var S5; + var S6; + var sh; + var sm; + var sx; + var ix; + var im; + var iy; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + + // Extract loop variables: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + sm = mask.strides; + if ( x.order === 'row-major' ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 6 ]; + S1 = sh[ 5 ]; + S2 = sh[ 4 ]; + S3 = sh[ 3 ]; + S4 = sh[ 2 ]; + S5 = sh[ 1 ]; + S6 = sh[ 0 ]; + dx0 = sx[ 6 ]; // offset increment for innermost loop + dx1 = sx[ 5 ] - ( S0*sx[6] ); + dx2 = sx[ 4 ] - ( S1*sx[5] ); + dx3 = sx[ 3 ] - ( S2*sx[4] ); + dx4 = sx[ 2 ] - ( S3*sx[3] ); + dx5 = sx[ 1 ] - ( S4*sx[2] ); + dx6 = sx[ 0 ] - ( S5*sx[1] ); // offset increment for outermost loop + dm0 = sm[ 6 ]; + dm1 = sm[ 5 ] - ( S0*sm[6] ); + dm2 = sm[ 4 ] - ( S1*sm[5] ); + dm3 = sm[ 3 ] - ( S2*sm[4] ); + dm4 = sm[ 2 ] - ( S3*sm[3] ); + dm5 = sm[ 1 ] - ( S4*sm[2] ); + dm6 = sm[ 0 ] - ( S5*sm[1] ); + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + S2 = sh[ 2 ]; + S3 = sh[ 3 ]; + S4 = sh[ 4 ]; + S5 = sh[ 5 ]; + S6 = sh[ 6 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); + dx2 = sx[ 2 ] - ( S1*sx[1] ); + dx3 = sx[ 3 ] - ( S2*sx[2] ); + dx4 = sx[ 4 ] - ( S3*sx[3] ); + dx5 = sx[ 5 ] - ( S4*sx[4] ); + dx6 = sx[ 6 ] - ( S5*sx[5] ); // offset increment for outermost loop + dm0 = sm[ 0 ]; + dm1 = sm[ 1 ] - ( S0*sm[0] ); + dm2 = sm[ 2 ] - ( S1*sm[1] ); + dm3 = sm[ 3 ] - ( S2*sm[2] ); + dm4 = sm[ 4 ] - ( S3*sm[3] ); + dm5 = sm[ 5 ] - ( S4*sm[4] ); + dm6 = sm[ 6 ] - ( S5*sm[5] ); + } + dy0 = y.strides[ 0 ]; + + // Set the pointers to the first indexed elements in the respective ndarrays... + ix = x.offset; + im = mask.offset; + iy = y.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + mbuf = mask.data; + ybuf = y.data; + + // Iterate over the ndarray dimensions... + for ( i6 = 0; i6 < S6; i6++ ) { + for ( i5 = 0; i5 < S5; i5++ ) { + for ( i4 = 0; i4 < S4; i4++ ) { + for ( i3 = 0; i3 < S3; i3++ ) { + for ( i2 = 0; i2 < S2; i2++ ) { + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( mbuf[ im ] ) { + ybuf[ iy ] = xbuf[ ix ]; + iy += dy0; + } + ix += dx0; + im += dm0; + } + ix += dx1; + im += dm1; + } + ix += dx2; + im += dm2; + } + ix += dx3; + im += dm3; + } + ix += dx4; + im += dm4; + } + ix += dx5; + im += dm5; + } + ix += dx6; + im += dm6; + } +} + + +// EXPORTS // + +module.exports = mskfilter7d; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_accessors.js new file mode 100644 index 00000000000..94830811afe --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_accessors.js @@ -0,0 +1,261 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-depth */ + +'use strict'; + +// MAIN // + +/** +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {Object} mask - object containing mask ndarray meta data +* @param {Object} y - object containing output ndarray meta data +* @returns {void} +* +* @example +* var BooleanArray = require( '@stdlib/array/bool' ); +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* var realf = require( '@stdlib/complex/realf' ); +* var imagf = require( '@stdlib/complex/imagf' ); +* +* // Define the shape of the array: +* var shape = [ 1, 1, 1, 1, 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 2, 2, 2, 2, 2, 2, 1 ]; +* var sm = [ 2, 2, 2, 2, 2, 2, 1 ]; +* var sy = [ 1 ]; +* +* // Define the index offset: +* var ox = 0; +* var om = 0; +* +* // Define getters and setters: +* function getter( buf, idx ) { +* return buf.get( idx ); +* } +* +* function setter( buf, idx, value ) { +* buf.set( value, idx ); +* } +* +* var x = { +* 'dtype': 'complex64', +* 'data': new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ), +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* var mask = { +* 'dtype': 'bool', +* 'data': new BooleanArray( [ 1, 0, 1, 0 ] ), +* 'shape': shape, +* 'strides': sm, +* 'offset': om, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* var y = { +* 'dtype': 'complex64', +* 'data': new Complex64Array( 2 ), +* 'shape': [ 2 ], +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* mskfilter7d( x, mask, y ); +* +* var v = y.data.get( 0 ); +* // returns +* +* var re = realf( v ); +* // returns 1.0 +* +* var im = imagf( v ); +* // returns 2.0 +* +* v = y.data.get( 1 ); +* // returns +* +* re = realf( v ); +* // returns 5.0 +* +* im = imagf( v ); +* // returns 6.0 +*/ +function mskfilter7d( x, mask, y ) { // eslint-disable-line max-statements + var xbuf; + var mbuf; + var ybuf; + var xget; + var mget; + var yset; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dx6; + var dm0; + var dm1; + var dm2; + var dm3; + var dm4; + var dm5; + var dm6; + var dy0; + var S0; + var S1; + var S2; + var S3; + var S4; + var S5; + var S6; + var sh; + var sm; + var sx; + var ix; + var im; + var iy; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + + // Extract loop variables: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + sm = mask.strides; + if ( x.order === 'row-major' ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 6 ]; + S1 = sh[ 5 ]; + S2 = sh[ 4 ]; + S3 = sh[ 3 ]; + S4 = sh[ 2 ]; + S5 = sh[ 1 ]; + S6 = sh[ 0 ]; + dx0 = sx[ 6 ]; // offset increment for innermost loop + dx1 = sx[ 5 ] - ( S0*sx[6] ); + dx2 = sx[ 4 ] - ( S1*sx[5] ); + dx3 = sx[ 3 ] - ( S2*sx[4] ); + dx4 = sx[ 2 ] - ( S3*sx[3] ); + dx5 = sx[ 1 ] - ( S4*sx[2] ); + dx6 = sx[ 0 ] - ( S5*sx[1] ); // offset increment for outermost loop + dm0 = sm[ 6 ]; + dm1 = sm[ 5 ] - ( S0*sm[6] ); + dm2 = sm[ 4 ] - ( S1*sm[5] ); + dm3 = sm[ 3 ] - ( S2*sm[4] ); + dm4 = sm[ 2 ] - ( S3*sm[3] ); + dm5 = sm[ 1 ] - ( S4*sm[2] ); + dm6 = sm[ 0 ] - ( S5*sm[1] ); + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + S2 = sh[ 2 ]; + S3 = sh[ 3 ]; + S4 = sh[ 4 ]; + S5 = sh[ 5 ]; + S6 = sh[ 6 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); + dx2 = sx[ 2 ] - ( S1*sx[1] ); + dx3 = sx[ 3 ] - ( S2*sx[2] ); + dx4 = sx[ 4 ] - ( S3*sx[3] ); + dx5 = sx[ 5 ] - ( S4*sx[4] ); + dx6 = sx[ 6 ] - ( S5*sx[5] ); // offset increment for outermost loop + dm0 = sm[ 0 ]; + dm1 = sm[ 1 ] - ( S0*sm[0] ); + dm2 = sm[ 2 ] - ( S1*sm[1] ); + dm3 = sm[ 3 ] - ( S2*sm[2] ); + dm4 = sm[ 4 ] - ( S3*sm[3] ); + dm5 = sm[ 5 ] - ( S4*sm[4] ); + dm6 = sm[ 6 ] - ( S5*sm[5] ); + } + dy0 = y.strides[ 0 ]; + + // Set the pointers to the first indexed elements in the respective ndarrays... + ix = x.offset; + im = mask.offset; + iy = y.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + mbuf = mask.data; + ybuf = y.data; + + // Cache accessors: + xget = x.accessors[ 0 ]; + mget = mask.accessors[ 0 ]; + yset = y.accessors[ 1 ]; + + // Iterate over the ndarray dimensions... + for ( i6 = 0; i6 < S6; i6++ ) { + for ( i5 = 0; i5 < S5; i5++ ) { + for ( i4 = 0; i4 < S4; i4++ ) { + for ( i3 = 0; i3 < S3; i3++ ) { + for ( i2 = 0; i2 < S2; i2++ ) { + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( mget( mbuf, im ) ) { + yset( ybuf, iy, xget( xbuf, ix ) ); + iy += dy0; + } + ix += dx0; + im += dm0; + } + ix += dx1; + im += dm1; + } + ix += dx2; + im += dm2; + } + ix += dx3; + im += dm3; + } + ix += dx4; + im += dm4; + } + ix += dx5; + im += dm5; + } + ix += dx6; + im += dm6; + } +} + + +// EXPORTS // + +module.exports = mskfilter7d; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_blocked.js new file mode 100644 index 00000000000..0f938a6d1c3 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_blocked.js @@ -0,0 +1,308 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-depth, max-len */ + +'use strict'; + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/unary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); + + +// MAIN // + +/** +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {Object} mask - object containing mask ndarray meta data +* @param {Object} y - object containing output ndarray meta data +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Uint8Array = require( '@stdlib/array/uint8' ); +* +* // Define the shape of the array: +* var shape = [ 1, 1, 1, 1, 3, 1, 2 ]; +* +* // Define the array strides: +* var sx = [ 12, 12, 12, 12, 4, 4, 1 ]; +* var sm = [ 6, 6, 6, 6, 2, 2, 1 ]; +* var sy = [ 1 ]; +* +* // Define the index offset: +* var ox = 1; +* var om = 0; +* +* var x = { +* 'dtype': 'float64', +* 'data': 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 ] ), +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* var mask = { +* 'dtype': 'uint8', +* 'data': new Uint8Array( [ 1, 0, 1, 0, 1, 0 ] ), +* 'shape': shape, +* 'strides': sm, +* 'offset': om, +* 'order': 'row-major' +* }; +* +* var y = { +* 'dtype': 'float64', +* 'data': new Float64Array( 3 ), +* 'shape': [ 3 ], +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major' +* }; +* +* blockedmskfilter7d( x, mask, y ); +* +* console.log( y.data ); +* // => [ 2.0, 6.0, 10.0 ] +*/ +function blockedmskfilter7d( x, mask, y ) { // eslint-disable-line max-statements + var bsize; + var xbuf; + var mbuf; + var ybuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dx6; + var dm0; + var dm1; + var dm2; + var dm3; + var dm4; + var dm5; + var dm6; + var dy0; + var ox1; + var ox2; + var ox3; + var ox4; + var ox5; + var ox6; + var om1; + var om2; + var om3; + var om4; + var om5; + var om6; + var sh; + var s0; + var s1; + var s2; + var s3; + var s4; + var s5; + var s6; + var sx; + var sm; + var ox; + var om; + var ix; + var im; + var iy; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + var j0; + var j1; + var j2; + var j3; + var j4; + var j5; + var j6; + var o; + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides, mask.strides ); + sh = o.sh; + sx = o.sx; + sm = o.sy; + + // Determine the block size: + bsize = blockSize( x.dtype, mask.dtype ); + + // Cache the indices of the first indexed elements in the respective ndarrays... + ox = x.offset; + om = mask.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + mbuf = mask.data; + ybuf = y.data; + + // Cache offset increments for the innermost loop... + dx0 = sx[0]; + dm0 = sm[0]; + dy0 = y.strides[0]; + + iy = y.offset; + + // Iterate over blocks... + for ( j6 = sh[6]; j6 > 0; ) { + if ( j6 < bsize ) { + s6 = j6; + j6 = 0; + } else { + s6 = bsize; + j6 -= bsize; + } + ox6 = ox + ( j6*sx[6] ); + om6 = om + ( j6*sm[6] ); + for ( j5 = sh[5]; j5 > 0; ) { + if ( j5 < bsize ) { + s5 = j5; + j5 = 0; + } else { + s5 = bsize; + j5 -= bsize; + } + dx6 = sx[6] - ( s5*sx[5] ); + dm6 = sm[6] - ( s5*sm[5] ); + ox5 = ox6 + ( j5*sx[5] ); + om5 = om6 + ( j5*sm[5] ); + for ( j4 = sh[4]; j4 > 0; ) { + if ( j4 < bsize ) { + s4 = j4; + j4 = 0; + } else { + s4 = bsize; + j4 -= bsize; + } + dx5 = sx[5] - ( s4*sx[4] ); + dm5 = sm[5] - ( s4*sm[4] ); + ox4 = ox5 + ( j4*sx[4] ); + om4 = om5 + ( j4*sm[4] ); + for ( j3 = sh[3]; j3 > 0; ) { + if ( j3 < bsize ) { + s3 = j3; + j3 = 0; + } else { + s3 = bsize; + j3 -= bsize; + } + dx4 = sx[4] - ( s3*sx[3] ); + dm4 = sm[4] - ( s3*sm[3] ); + ox3 = ox4 + ( j3*sx[3] ); + om3 = om4 + ( j3*sm[3] ); + for ( j2 = sh[2]; j2 > 0; ) { + if ( j2 < bsize ) { + s2 = j2; + j2 = 0; + } else { + s2 = bsize; + j2 -= bsize; + } + dx3 = sx[3] - ( s2*sx[2] ); + dm3 = sm[3] - ( s2*sm[2] ); + ox2 = ox3 + ( j2*sx[2] ); + om2 = om3 + ( j2*sm[2] ); + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + dx2 = sx[2] - ( s1*sx[1] ); + dm2 = sm[2] - ( s1*sm[1] ); + ox1 = ox2 + ( j1*sx[1] ); + om1 = om2 + ( j1*sm[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute index offsets for the first input and output ndarray elements in the current block... + ix = ox1 + ( j0*sx[0] ); + im = om1 + ( j0*sm[0] ); + + // Compute loop offset increments... + dx1 = sx[1] - ( s0*sx[0] ); + dm1 = sm[1] - ( s0*sm[0] ); + + // Iterate over the ndarray dimensions... + for ( i6 = 0; i6 < s6; i6++ ) { + for ( i5 = 0; i5 < s5; i5++ ) { + for ( i4 = 0; i4 < s4; i4++ ) { + for ( i3 = 0; i3 < s3; i3++ ) { + for ( i2 = 0; i2 < s2; i2++ ) { + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( mbuf[ im ] ) { + ybuf[ iy ] = xbuf[ ix ]; + iy += dy0; + } + ix += dx0; + im += dm0; + } + ix += dx1; + im += dm1; + } + ix += dx2; + im += dm2; + } + ix += dx3; + im += dm3; + } + ix += dx4; + im += dm4; + } + ix += dx5; + im += dm5; + } + ix += dx6; + im += dm6; + } + } + } + } + } + } + } + } +} + + +// EXPORTS // + +module.exports = blockedmskfilter7d; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_blocked_accessors.js new file mode 100644 index 00000000000..9fd7fcc115e --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_blocked_accessors.js @@ -0,0 +1,346 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-depth, max-len */ + +'use strict'; + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/unary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); + + +// MAIN // + +/** +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {Object} mask - object containing mask ndarray meta data +* @param {Object} y - object containing output ndarray meta data +* @returns {void} +* +* @example +* var BooleanArray = require( '@stdlib/array/bool' ); +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* var realf = require( '@stdlib/complex/realf' ); +* var imagf = require( '@stdlib/complex/imagf' ); +* +* // Define the shape of the array: +* var shape = [ 1, 1, 1, 1, 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 2, 2, 2, 2, 2, 2, 1 ]; +* var sm = [ 2, 2, 2, 2, 2, 2, 1 ]; +* var sy = [ 1 ]; +* +* // Define the index offset: +* var ox = 0; +* var om = 0; +* +* // Define getters and setters: +* function getter( buf, idx ) { +* return buf.get( idx ); +* } +* +* function setter( buf, idx, value ) { +* buf.set( value, idx ); +* } +* +* var x = { +* 'dtype': 'complex64', +* 'data': new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ), +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* var mask = { +* 'dtype': 'bool', +* 'data': new BooleanArray( [ 1, 0, 1, 0 ] ), +* 'shape': shape, +* 'strides': sm, +* 'offset': om, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* var y = { +* 'dtype': 'complex64', +* 'data': new Complex64Array( 2 ), +* 'shape': [ 2 ], +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* blockedmskfilter7d( x, mask, y ); +* +* var v = y.data.get( 0 ); +* // returns +* +* var re = realf( v ); +* // returns 1.0 +* +* var im = imagf( v ); +* // returns 2.0 +* +* v = y.data.get( 1 ); +* // returns +* +* re = realf( v ); +* // returns 5.0 +* +* im = imagf( v ); +* // returns 6.0 +*/ +function blockedmskfilter7d( x, mask, y ) { // eslint-disable-line max-statements, max-lines-per-function + var bsize; + var xbuf; + var mbuf; + var ybuf; + var xget; + var mget; + var yset; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dx6; + var dm0; + var dm1; + var dm2; + var dm3; + var dm4; + var dm5; + var dm6; + var dy0; + var ox1; + var ox2; + var ox3; + var ox4; + var ox5; + var ox6; + var om1; + var om2; + var om3; + var om4; + var om5; + var om6; + var sh; + var s0; + var s1; + var s2; + var s3; + var s4; + var s5; + var s6; + var sx; + var sm; + var ox; + var om; + var ix; + var im; + var iy; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + var j0; + var j1; + var j2; + var j3; + var j4; + var j5; + var j6; + var o; + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides, mask.strides ); + sh = o.sh; + sx = o.sx; + sm = o.sy; + + // Determine the block size: + bsize = blockSize( x.dtype, mask.dtype ); + + // Cache the indices of the first indexed elements in the respective ndarrays... + ox = x.offset; + om = mask.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + mbuf = mask.data; + ybuf = y.data; + + // Cache offset increments for the innermost loop... + dx0 = sx[0]; + dm0 = sm[0]; + dy0 = y.strides[0]; + + iy = y.offset; + + // Cache accessors: + xget = x.accessors[ 0 ]; + mget = mask.accessors[ 0 ]; + yset = y.accessors[ 1 ]; + + // Iterate over blocks... + for ( j6 = sh[6]; j6 > 0; ) { + if ( j6 < bsize ) { + s6 = j6; + j6 = 0; + } else { + s6 = bsize; + j6 -= bsize; + } + ox6 = ox + ( j6*sx[6] ); + om6 = om + ( j6*sm[6] ); + for ( j5 = sh[5]; j5 > 0; ) { + if ( j5 < bsize ) { + s5 = j5; + j5 = 0; + } else { + s5 = bsize; + j5 -= bsize; + } + dx6 = sx[6] - ( s5*sx[5] ); + dm6 = sm[6] - ( s5*sm[5] ); + ox5 = ox6 + ( j5*sx[5] ); + om5 = om6 + ( j5*sm[5] ); + for ( j4 = sh[4]; j4 > 0; ) { + if ( j4 < bsize ) { + s4 = j4; + j4 = 0; + } else { + s4 = bsize; + j4 -= bsize; + } + dx5 = sx[5] - ( s4*sx[4] ); + dm5 = sm[5] - ( s4*sm[4] ); + ox4 = ox5 + ( j4*sx[4] ); + om4 = om5 + ( j4*sm[4] ); + for ( j3 = sh[3]; j3 > 0; ) { + if ( j3 < bsize ) { + s3 = j3; + j3 = 0; + } else { + s3 = bsize; + j3 -= bsize; + } + dx4 = sx[4] - ( s3*sx[3] ); + dm4 = sm[4] - ( s3*sm[3] ); + ox3 = ox4 + ( j3*sx[3] ); + om3 = om4 + ( j3*sm[3] ); + for ( j2 = sh[2]; j2 > 0; ) { + if ( j2 < bsize ) { + s2 = j2; + j2 = 0; + } else { + s2 = bsize; + j2 -= bsize; + } + dx3 = sx[3] - ( s2*sx[2] ); + dm3 = sm[3] - ( s2*sm[2] ); + ox2 = ox3 + ( j2*sx[2] ); + om2 = om3 + ( j2*sm[2] ); + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + dx2 = sx[2] - ( s1*sx[1] ); + dm2 = sm[2] - ( s1*sm[1] ); + ox1 = ox2 + ( j1*sx[1] ); + om1 = om2 + ( j1*sm[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute index offsets for the first input and output ndarray elements in the current block... + ix = ox1 + ( j0*sx[0] ); + im = om1 + ( j0*sm[0] ); + + // Compute loop offset increments... + dx1 = sx[1] - ( s0*sx[0] ); + dm1 = sm[1] - ( s0*sm[0] ); + + // Iterate over the ndarray dimensions... + for ( i6 = 0; i6 < s6; i6++ ) { + for ( i5 = 0; i5 < s5; i5++ ) { + for ( i4 = 0; i4 < s4; i4++ ) { + for ( i3 = 0; i3 < s3; i3++ ) { + for ( i2 = 0; i2 < s2; i2++ ) { + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( mget( mbuf, im ) ) { + yset( ybuf, iy, xget( xbuf, ix ) ); + iy += dy0; + } + ix += dx0; + im += dm0; + } + ix += dx1; + im += dm1; + } + ix += dx2; + im += dm2; + } + ix += dx3; + im += dm3; + } + ix += dx4; + im += dm4; + } + ix += dx5; + im += dm5; + } + ix += dx6; + im += dm6; + } + } + } + } + } + } + } + } +} + + +// EXPORTS // + +module.exports = blockedmskfilter7d; From ad939d1b5dc1bea98d374cead2a6c9a89d832895 Mon Sep 17 00:00:00 2001 From: Jaysukh-409 Date: Mon, 5 Aug 2024 19:31:41 +0530 Subject: [PATCH 15/34] feat: add kernels for 8d ndarray --- .../@stdlib/ndarray/base/mskfilter/lib/8d.js | 237 +++++++++++ .../base/mskfilter/lib/8d_accessors.js | 275 +++++++++++++ .../ndarray/base/mskfilter/lib/8d_blocked.js | 332 ++++++++++++++++ .../mskfilter/lib/8d_blocked_accessors.js | 370 ++++++++++++++++++ 4 files changed, 1214 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_blocked.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_blocked_accessors.js diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d.js new file mode 100644 index 00000000000..10b5b4b6969 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d.js @@ -0,0 +1,237 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-depth */ + +'use strict'; + +// MAIN // + +/** +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {Object} mask - object containing mask ndarray meta data +* @param {Object} y - object containing output ndarray meta data +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Uint8Array = require( '@stdlib/array/uint8' ); +* +* // Define the shape of the array: +* var shape = [ 1, 1, 1, 1, 1, 3, 1, 2 ]; +* +* // Define the array strides: +* var sx = [ 12, 12, 12, 12, 12, 4, 4, 1 ]; +* var sm = [ 6, 6, 6, 6, 6, 2, 2, 1 ]; +* var sy = [ 1 ]; +* +* // Define the index offset: +* var ox = 1; +* var om = 0; +* +* var x = { +* 'dtype': 'float64', +* 'data': 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 ] ), +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* var mask = { +* 'dtype': 'uint8', +* 'data': new Uint8Array( [ 1, 0, 1, 0, 1, 0 ] ), +* 'shape': shape, +* 'strides': sm, +* 'offset': om, +* 'order': 'row-major' +* }; +* +* var y = { +* 'dtype': 'float64', +* 'data': new Float64Array( 3 ), +* 'shape': [ 3 ], +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major' +* }; +* +* mskfilter8d( x, mask, y ); +* +* console.log( y.data ); +* // => [ 2.0, 6.0, 10.0 ] +*/ +function mskfilter8d( x, mask, y ) { // eslint-disable-line max-statements + var xbuf; + var mbuf; + var ybuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dx6; + var dx7; + var dm0; + var dm1; + var dm2; + var dm3; + var dm4; + var dm5; + var dm6; + var dm7; + var dy0; + var S0; + var S1; + var S2; + var S3; + var S4; + var S5; + var S6; + var S7; + var sh; + var sm; + var sx; + var ix; + var im; + var iy; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + var i7; + + // Extract loop variables: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + sm = mask.strides; + if ( x.order === 'row-major' ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 7 ]; + S1 = sh[ 6 ]; + S2 = sh[ 5 ]; + S3 = sh[ 4 ]; + S4 = sh[ 3 ]; + S5 = sh[ 2 ]; + S6 = sh[ 1 ]; + S7 = sh[ 0 ]; + dx0 = sx[ 7 ]; // offset increment for innermost loop + dx1 = sx[ 6 ] - ( S0*sx[7] ); + dx2 = sx[ 5 ] - ( S1*sx[6] ); + dx3 = sx[ 4 ] - ( S2*sx[5] ); + dx4 = sx[ 3 ] - ( S3*sx[4] ); + dx5 = sx[ 2 ] - ( S4*sx[3] ); + dx6 = sx[ 1 ] - ( S5*sx[2] ); + dx7 = sx[ 0 ] - ( S6*sx[1] ); // offset increment for outermost loop + dm0 = sm[ 7 ]; + dm1 = sm[ 6 ] - ( S0*sm[7] ); + dm2 = sm[ 5 ] - ( S1*sm[6] ); + dm3 = sm[ 4 ] - ( S2*sm[5] ); + dm4 = sm[ 3 ] - ( S3*sm[4] ); + dm5 = sm[ 2 ] - ( S4*sm[3] ); + dm6 = sm[ 1 ] - ( S5*sm[2] ); + dm7 = sm[ 0 ] - ( S6*sm[1] ); + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + S2 = sh[ 2 ]; + S3 = sh[ 3 ]; + S4 = sh[ 4 ]; + S5 = sh[ 5 ]; + S6 = sh[ 6 ]; + S7 = sh[ 7 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); + dx2 = sx[ 2 ] - ( S1*sx[1] ); + dx3 = sx[ 3 ] - ( S2*sx[2] ); + dx4 = sx[ 4 ] - ( S3*sx[3] ); + dx5 = sx[ 5 ] - ( S4*sx[4] ); + dx6 = sx[ 6 ] - ( S5*sx[5] ); + dx7 = sx[ 7 ] - ( S6*sx[6] ); // offset increment for outermost loop + dm0 = sm[ 0 ]; + dm1 = sm[ 1 ] - ( S0*sm[0] ); + dm2 = sm[ 2 ] - ( S1*sm[1] ); + dm3 = sm[ 3 ] - ( S2*sm[2] ); + dm4 = sm[ 4 ] - ( S3*sm[3] ); + dm5 = sm[ 5 ] - ( S4*sm[4] ); + dm6 = sm[ 6 ] - ( S5*sm[5] ); + dm7 = sm[ 7 ] - ( S6*sm[6] ); + } + dy0 = y.strides[ 0 ]; + + // Set the pointers to the first indexed elements in the respective ndarrays... + ix = x.offset; + im = mask.offset; + iy = y.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + mbuf = mask.data; + ybuf = y.data; + + // Iterate over the ndarray dimensions... + for ( i7 = 0; i7 < S7; i7++ ) { + for ( i6 = 0; i6 < S6; i6++ ) { + for ( i5 = 0; i5 < S5; i5++ ) { + for ( i4 = 0; i4 < S4; i4++ ) { + for ( i3 = 0; i3 < S3; i3++ ) { + for ( i2 = 0; i2 < S2; i2++ ) { + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( mbuf[ im ] ) { + ybuf[ iy ] = xbuf[ ix ]; + iy += dy0; + } + ix += dx0; + im += dm0; + } + ix += dx1; + im += dm1; + } + ix += dx2; + im += dm2; + } + ix += dx3; + im += dm3; + } + ix += dx4; + im += dm4; + } + ix += dx5; + im += dm5; + } + ix += dx6; + im += dm6; + } + ix += dx7; + im += dm7; + } +} + + +// EXPORTS // + +module.exports = mskfilter8d; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_accessors.js new file mode 100644 index 00000000000..17ee8fd8ae9 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_accessors.js @@ -0,0 +1,275 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-depth */ + +'use strict'; + +// MAIN // + +/** +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {Object} mask - object containing mask ndarray meta data +* @param {Object} y - object containing output ndarray meta data +* @returns {void} +* +* @example +* var BooleanArray = require( '@stdlib/array/bool' ); +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* var realf = require( '@stdlib/complex/realf' ); +* var imagf = require( '@stdlib/complex/imagf' ); +* +* // Define the shape of the array: +* var shape = [ 1, 1, 1, 1, 1, 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 2, 2, 2, 2, 2, 2, 2, 1 ]; +* var sm = [ 2, 2, 2, 2, 2, 2, 2, 1 ]; +* var sy = [ 1 ]; +* +* // Define the index offset: +* var ox = 0; +* var om = 0; +* +* // Define getters and setters: +* function getter( buf, idx ) { +* return buf.get( idx ); +* } +* +* function setter( buf, idx, value ) { +* buf.set( value, idx ); +* } +* +* var x = { +* 'dtype': 'complex64', +* 'data': new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ), +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* var mask = { +* 'dtype': 'bool', +* 'data': new BooleanArray( [ 1, 0, 1, 0 ] ), +* 'shape': shape, +* 'strides': sm, +* 'offset': om, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* var y = { +* 'dtype': 'complex64', +* 'data': new Complex64Array( 2 ), +* 'shape': [ 2 ], +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* mskfilter8d( x, mask, y ); +* +* var v = y.data.get( 0 ); +* // returns +* +* var re = realf( v ); +* // returns 1.0 +* +* var im = imagf( v ); +* // returns 2.0 +* +* v = y.data.get( 1 ); +* // returns +* +* re = realf( v ); +* // returns 5.0 +* +* im = imagf( v ); +* // returns 6.0 +*/ +function mskfilter8d( x, mask, y ) { // eslint-disable-line max-statements + var xbuf; + var mbuf; + var ybuf; + var xget; + var mget; + var yset; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dx6; + var dx7; + var dm0; + var dm1; + var dm2; + var dm3; + var dm4; + var dm5; + var dm6; + var dm7; + var dy0; + var S0; + var S1; + var S2; + var S3; + var S4; + var S5; + var S6; + var S7; + var sh; + var sm; + var sx; + var ix; + var im; + var iy; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + var i7; + + // Extract loop variables: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + sm = mask.strides; + if ( x.order === 'row-major' ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 7 ]; + S1 = sh[ 6 ]; + S2 = sh[ 5 ]; + S3 = sh[ 4 ]; + S4 = sh[ 3 ]; + S5 = sh[ 2 ]; + S6 = sh[ 1 ]; + S7 = sh[ 0 ]; + dx0 = sx[ 7 ]; // offset increment for innermost loop + dx1 = sx[ 6 ] - ( S0*sx[7] ); + dx2 = sx[ 5 ] - ( S1*sx[6] ); + dx3 = sx[ 4 ] - ( S2*sx[5] ); + dx4 = sx[ 3 ] - ( S3*sx[4] ); + dx5 = sx[ 2 ] - ( S4*sx[3] ); + dx6 = sx[ 1 ] - ( S5*sx[2] ); + dx7 = sx[ 0 ] - ( S6*sx[1] ); // offset increment for outermost loop + dm0 = sm[ 7 ]; + dm1 = sm[ 6 ] - ( S0*sm[7] ); + dm2 = sm[ 5 ] - ( S1*sm[6] ); + dm3 = sm[ 4 ] - ( S2*sm[5] ); + dm4 = sm[ 3 ] - ( S3*sm[4] ); + dm5 = sm[ 2 ] - ( S4*sm[3] ); + dm6 = sm[ 1 ] - ( S5*sm[2] ); + dm7 = sm[ 0 ] - ( S6*sm[1] ); + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + S2 = sh[ 2 ]; + S3 = sh[ 3 ]; + S4 = sh[ 4 ]; + S5 = sh[ 5 ]; + S6 = sh[ 6 ]; + S7 = sh[ 7 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); + dx2 = sx[ 2 ] - ( S1*sx[1] ); + dx3 = sx[ 3 ] - ( S2*sx[2] ); + dx4 = sx[ 4 ] - ( S3*sx[3] ); + dx5 = sx[ 5 ] - ( S4*sx[4] ); + dx6 = sx[ 6 ] - ( S5*sx[5] ); + dx7 = sx[ 7 ] - ( S6*sx[6] ); // offset increment for outermost loop + dm0 = sm[ 0 ]; + dm1 = sm[ 1 ] - ( S0*sm[0] ); + dm2 = sm[ 2 ] - ( S1*sm[1] ); + dm3 = sm[ 3 ] - ( S2*sm[2] ); + dm4 = sm[ 4 ] - ( S3*sm[3] ); + dm5 = sm[ 5 ] - ( S4*sm[4] ); + dm6 = sm[ 6 ] - ( S5*sm[5] ); + dm7 = sm[ 7 ] - ( S6*sm[6] ); + } + dy0 = y.strides[ 0 ]; + + // Set the pointers to the first indexed elements in the respective ndarrays... + ix = x.offset; + im = mask.offset; + iy = y.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + mbuf = mask.data; + ybuf = y.data; + + // Cache accessors: + xget = x.accessors[ 0 ]; + mget = mask.accessors[ 0 ]; + yset = y.accessors[ 1 ]; + + // Iterate over the ndarray dimensions... + for ( i7 = 0; i7 < S7; i7++ ) { + for ( i6 = 0; i6 < S6; i6++ ) { + for ( i5 = 0; i5 < S5; i5++ ) { + for ( i4 = 0; i4 < S4; i4++ ) { + for ( i3 = 0; i3 < S3; i3++ ) { + for ( i2 = 0; i2 < S2; i2++ ) { + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( mget( mbuf, im ) ) { + yset( ybuf, iy, xget( xbuf, ix ) ); + iy += dy0; + } + ix += dx0; + im += dm0; + } + ix += dx1; + im += dm1; + } + ix += dx2; + im += dm2; + } + ix += dx3; + im += dm3; + } + ix += dx4; + im += dm4; + } + ix += dx5; + im += dm5; + } + ix += dx6; + im += dm6; + } + ix += dx7; + im += dm7; + } +} + + +// EXPORTS // + +module.exports = mskfilter8d; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_blocked.js new file mode 100644 index 00000000000..e2e25532bb3 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_blocked.js @@ -0,0 +1,332 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-depth, max-len */ + +'use strict'; + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/unary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); + + +// MAIN // + +/** +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {Object} mask - object containing mask ndarray meta data +* @param {Object} y - object containing output ndarray meta data +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Uint8Array = require( '@stdlib/array/uint8' ); +* +* // Define the shape of the array: +* var shape = [ 1, 1, 1, 1, 1, 3, 1, 2 ]; +* +* // Define the array strides: +* var sx = [ 12, 12, 12, 12, 12, 4, 4, 1 ]; +* var sm = [ 6, 6, 6, 6, 6, 2, 2, 1 ]; +* var sy = [ 1 ]; +* +* // Define the index offset: +* var ox = 1; +* var om = 0; +* +* var x = { +* 'dtype': 'float64', +* 'data': 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 ] ), +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* var mask = { +* 'dtype': 'uint8', +* 'data': new Uint8Array( [ 1, 0, 1, 0, 1, 0 ] ), +* 'shape': shape, +* 'strides': sm, +* 'offset': om, +* 'order': 'row-major' +* }; +* +* var y = { +* 'dtype': 'float64', +* 'data': new Float64Array( 3 ), +* 'shape': [ 3 ], +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major' +* }; +* +* blockedmskfilter8d( x, mask, y ); +* +* console.log( y.data ); +* // => [ 2.0, 6.0, 10.0 ] +*/ +function blockedmskfilter8d( x, mask, y ) { // eslint-disable-line max-statements, max-lines-per-function + var bsize; + var xbuf; + var mbuf; + var ybuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dx6; + var dx7; + var dm0; + var dm1; + var dm2; + var dm3; + var dm4; + var dm5; + var dm6; + var dm7; + var dy0; + var ox1; + var ox2; + var ox3; + var ox4; + var ox5; + var ox6; + var ox7; + var om1; + var om2; + var om3; + var om4; + var om5; + var om6; + var om7; + var sh; + var s0; + var s1; + var s2; + var s3; + var s4; + var s5; + var s6; + var s7; + var sx; + var sm; + var ox; + var om; + var ix; + var im; + var iy; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + var i7; + var j0; + var j1; + var j2; + var j3; + var j4; + var j5; + var j6; + var j7; + var o; + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides, mask.strides ); + sh = o.sh; + sx = o.sx; + sm = o.sy; + + // Determine the block size: + bsize = blockSize( x.dtype, mask.dtype ); + + // Cache the indices of the first indexed elements in the respective ndarrays... + ox = x.offset; + om = mask.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + mbuf = mask.data; + ybuf = y.data; + + // Cache offset increments for the innermost loop... + dx0 = sx[0]; + dm0 = sm[0]; + dy0 = y.strides[0]; + + iy = y.offset; + + // Iterate over blocks... + for ( j7 = sh[7]; j7 > 0; ) { + if ( j7 < bsize ) { + s7 = j7; + j7 = 0; + } else { + s7 = bsize; + j7 -= bsize; + } + ox7 = ox + ( j7*sx[7] ); + om7 = om + ( j7*sm[7] ); + for ( j6 = sh[6]; j6 > 0; ) { + if ( j6 < bsize ) { + s6 = j6; + j6 = 0; + } else { + s6 = bsize; + j6 -= bsize; + } + dx7 = sx[7] - ( s6*sx[6] ); + dm7 = sm[7] - ( s6*sm[6] ); + ox6 = ox7 + ( j6*sx[6] ); + om6 = om7 + ( j6*sm[6] ); + for ( j5 = sh[5]; j5 > 0; ) { + if ( j5 < bsize ) { + s5 = j5; + j5 = 0; + } else { + s5 = bsize; + j5 -= bsize; + } + dx6 = sx[6] - ( s5*sx[5] ); + dm6 = sm[6] - ( s5*sm[5] ); + ox5 = ox6 + ( j5*sx[5] ); + om5 = om6 + ( j5*sm[5] ); + for ( j4 = sh[4]; j4 > 0; ) { + if ( j4 < bsize ) { + s4 = j4; + j4 = 0; + } else { + s4 = bsize; + j4 -= bsize; + } + dx5 = sx[5] - ( s4*sx[4] ); + dm5 = sm[5] - ( s4*sm[4] ); + ox4 = ox5 + ( j4*sx[4] ); + om4 = om5 + ( j4*sm[4] ); + for ( j3 = sh[3]; j3 > 0; ) { + if ( j3 < bsize ) { + s3 = j3; + j3 = 0; + } else { + s3 = bsize; + j3 -= bsize; + } + dx4 = sx[4] - ( s3*sx[3] ); + dm4 = sm[4] - ( s3*sm[3] ); + ox3 = ox4 + ( j3*sx[3] ); + om3 = om4 + ( j3*sm[3] ); + for ( j2 = sh[2]; j2 > 0; ) { + if ( j2 < bsize ) { + s2 = j2; + j2 = 0; + } else { + s2 = bsize; + j2 -= bsize; + } + dx3 = sx[3] - ( s2*sx[2] ); + dm3 = sm[3] - ( s2*sm[2] ); + ox2 = ox3 + ( j2*sx[2] ); + om2 = om3 + ( j2*sm[2] ); + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + dx2 = sx[2] - ( s1*sx[1] ); + dm2 = sm[2] - ( s1*sm[1] ); + ox1 = ox2 + ( j1*sx[1] ); + om1 = om2 + ( j1*sm[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute index offsets for the first input and output ndarray elements in the current block... + ix = ox1 + ( j0*sx[0] ); + im = om1 + ( j0*sm[0] ); + + // Compute loop offset increments... + dx1 = sx[1] - ( s0*sx[0] ); + dm1 = sm[1] - ( s0*sm[0] ); + + // Iterate over the ndarray dimensions... + for ( i7 = 0; i7 < s7; i7++ ) { + for ( i6 = 0; i6 < s6; i6++ ) { + for ( i5 = 0; i5 < s5; i5++ ) { + for ( i4 = 0; i4 < s4; i4++ ) { + for ( i3 = 0; i3 < s3; i3++ ) { + for ( i2 = 0; i2 < s2; i2++ ) { + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( mbuf[ im ] ) { + ybuf[ iy ] = xbuf[ ix ]; + iy += dy0; + } + ix += dx0; + im += dm0; + } + ix += dx1; + im += dm1; + } + ix += dx2; + im += dm2; + } + ix += dx3; + im += dm3; + } + ix += dx4; + im += dm4; + } + ix += dx5; + im += dm5; + } + ix += dx6; + im += dm6; + } + ix += dx7; + im += dm7; + } + } + } + } + } + } + } + } + } +} + + +// EXPORTS // + +module.exports = blockedmskfilter8d; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_blocked_accessors.js new file mode 100644 index 00000000000..728f2a5d421 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_blocked_accessors.js @@ -0,0 +1,370 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-depth, max-len */ + +'use strict'; + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/unary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); + + +// MAIN // + +/** +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {Object} mask - object containing mask ndarray meta data +* @param {Object} y - object containing output ndarray meta data +* @returns {void} +* +* @example +* var BooleanArray = require( '@stdlib/array/bool' ); +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* var realf = require( '@stdlib/complex/realf' ); +* var imagf = require( '@stdlib/complex/imagf' ); +* +* // Define the shape of the array: +* var shape = [ 1, 1, 1, 1, 1, 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 2, 2, 2, 2, 2, 2, 2, 1 ]; +* var sm = [ 2, 2, 2, 2, 2, 2, 2, 1 ]; +* var sy = [ 1 ]; +* +* // Define the index offset: +* var ox = 0; +* var om = 0; +* +* // Define getters and setters: +* function getter( buf, idx ) { +* return buf.get( idx ); +* } +* +* function setter( buf, idx, value ) { +* buf.set( value, idx ); +* } +* +* var x = { +* 'dtype': 'complex64', +* 'data': new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ), +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* var mask = { +* 'dtype': 'bool', +* 'data': new BooleanArray( [ 1, 0, 1, 0 ] ), +* 'shape': shape, +* 'strides': sm, +* 'offset': om, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* var y = { +* 'dtype': 'complex64', +* 'data': new Complex64Array( 2 ), +* 'shape': [ 2 ], +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* blockedmskfilter8d( x, mask, y ); +* +* var v = y.data.get( 0 ); +* // returns +* +* var re = realf( v ); +* // returns 1.0 +* +* var im = imagf( v ); +* // returns 2.0 +* +* v = y.data.get( 1 ); +* // returns +* +* re = realf( v ); +* // returns 5.0 +* +* im = imagf( v ); +* // returns 6.0 +*/ +function blockedmskfilter8d( x, mask, y ) { // eslint-disable-line max-statements, max-lines-per-function + var bsize; + var xbuf; + var mbuf; + var ybuf; + var xget; + var mget; + var yset; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dx6; + var dx7; + var dm0; + var dm1; + var dm2; + var dm3; + var dm4; + var dm5; + var dm6; + var dm7; + var dy0; + var ox1; + var ox2; + var ox3; + var ox4; + var ox5; + var ox6; + var ox7; + var om1; + var om2; + var om3; + var om4; + var om5; + var om6; + var om7; + var sh; + var s0; + var s1; + var s2; + var s3; + var s4; + var s5; + var s6; + var s7; + var sx; + var sm; + var ox; + var om; + var ix; + var im; + var iy; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + var i7; + var j0; + var j1; + var j2; + var j3; + var j4; + var j5; + var j6; + var j7; + var o; + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides, mask.strides ); + sh = o.sh; + sx = o.sx; + sm = o.sy; + + // Determine the block size: + bsize = blockSize( x.dtype, mask.dtype ); + + // Cache the indices of the first indexed elements in the respective ndarrays... + ox = x.offset; + om = mask.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + mbuf = mask.data; + ybuf = y.data; + + // Cache offset increments for the innermost loop... + dx0 = sx[0]; + dm0 = sm[0]; + dy0 = y.strides[0]; + + iy = y.offset; + + // Cache accessors: + xget = x.accessors[ 0 ]; + mget = mask.accessors[ 0 ]; + yset = y.accessors[ 1 ]; + + // Iterate over blocks... + for ( j7 = sh[7]; j7 > 0; ) { + if ( j7 < bsize ) { + s7 = j7; + j7 = 0; + } else { + s7 = bsize; + j7 -= bsize; + } + ox7 = ox + ( j7*sx[7] ); + om7 = om + ( j7*sm[7] ); + for ( j6 = sh[6]; j6 > 0; ) { + if ( j6 < bsize ) { + s6 = j6; + j6 = 0; + } else { + s6 = bsize; + j6 -= bsize; + } + dx7 = sx[7] - ( s6*sx[6] ); + dm7 = sm[7] - ( s6*sm[6] ); + ox6 = ox7 + ( j6*sx[6] ); + om6 = om7 + ( j6*sm[6] ); + for ( j5 = sh[5]; j5 > 0; ) { + if ( j5 < bsize ) { + s5 = j5; + j5 = 0; + } else { + s5 = bsize; + j5 -= bsize; + } + dx6 = sx[6] - ( s5*sx[5] ); + dm6 = sm[6] - ( s5*sm[5] ); + ox5 = ox6 + ( j5*sx[5] ); + om5 = om6 + ( j5*sm[5] ); + for ( j4 = sh[4]; j4 > 0; ) { + if ( j4 < bsize ) { + s4 = j4; + j4 = 0; + } else { + s4 = bsize; + j4 -= bsize; + } + dx5 = sx[5] - ( s4*sx[4] ); + dm5 = sm[5] - ( s4*sm[4] ); + ox4 = ox5 + ( j4*sx[4] ); + om4 = om5 + ( j4*sm[4] ); + for ( j3 = sh[3]; j3 > 0; ) { + if ( j3 < bsize ) { + s3 = j3; + j3 = 0; + } else { + s3 = bsize; + j3 -= bsize; + } + dx4 = sx[4] - ( s3*sx[3] ); + dm4 = sm[4] - ( s3*sm[3] ); + ox3 = ox4 + ( j3*sx[3] ); + om3 = om4 + ( j3*sm[3] ); + for ( j2 = sh[2]; j2 > 0; ) { + if ( j2 < bsize ) { + s2 = j2; + j2 = 0; + } else { + s2 = bsize; + j2 -= bsize; + } + dx3 = sx[3] - ( s2*sx[2] ); + dm3 = sm[3] - ( s2*sm[2] ); + ox2 = ox3 + ( j2*sx[2] ); + om2 = om3 + ( j2*sm[2] ); + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + dx2 = sx[2] - ( s1*sx[1] ); + dm2 = sm[2] - ( s1*sm[1] ); + ox1 = ox2 + ( j1*sx[1] ); + om1 = om2 + ( j1*sm[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute index offsets for the first input and output ndarray elements in the current block... + ix = ox1 + ( j0*sx[0] ); + im = om1 + ( j0*sm[0] ); + + // Compute loop offset increments... + dx1 = sx[1] - ( s0*sx[0] ); + dm1 = sm[1] - ( s0*sm[0] ); + + // Iterate over the ndarray dimensions... + for ( i7 = 0; i7 < s7; i7++ ) { + for ( i6 = 0; i6 < s6; i6++ ) { + for ( i5 = 0; i5 < s5; i5++ ) { + for ( i4 = 0; i4 < s4; i4++ ) { + for ( i3 = 0; i3 < s3; i3++ ) { + for ( i2 = 0; i2 < s2; i2++ ) { + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( mget( mbuf, im ) ) { + yset( ybuf, iy, xget( xbuf, ix ) ); + iy += dy0; + } + ix += dx0; + im += dm0; + } + ix += dx1; + im += dm1; + } + ix += dx2; + im += dm2; + } + ix += dx3; + im += dm3; + } + ix += dx4; + im += dm4; + } + ix += dx5; + im += dm5; + } + ix += dx6; + im += dm6; + } + ix += dx7; + im += dm7; + } + } + } + } + } + } + } + } + } +} + + +// EXPORTS // + +module.exports = blockedmskfilter8d; From f14984701cfe9b319bb16e1b32dfbe58d9d60202 Mon Sep 17 00:00:00 2001 From: Jaysukh-409 Date: Mon, 5 Aug 2024 19:46:54 +0530 Subject: [PATCH 16/34] feat: add kernels for 9d ndarray --- .../@stdlib/ndarray/base/mskfilter/lib/9d.js | 251 +++++++++++ .../base/mskfilter/lib/9d_accessors.js | 289 +++++++++++++ .../ndarray/base/mskfilter/lib/9d_blocked.js | 356 ++++++++++++++++ .../mskfilter/lib/9d_blocked_accessors.js | 394 ++++++++++++++++++ 4 files changed, 1290 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_blocked.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_blocked_accessors.js diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d.js new file mode 100644 index 00000000000..83d1983aad3 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d.js @@ -0,0 +1,251 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-depth */ + +'use strict'; + +// MAIN // + +/** +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {Object} mask - object containing mask ndarray meta data +* @param {Object} y - object containing output ndarray meta data +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Uint8Array = require( '@stdlib/array/uint8' ); +* +* // Define the shape of the array: +* var shape = [ 1, 1, 1, 1, 1, 1, 3, 1, 2 ]; +* +* // Define the array strides: +* var sx = [ 12, 12, 12, 12, 12, 12, 4, 4, 1 ]; +* var sm = [ 6, 6, 6, 6, 6, 6, 2, 2, 1 ]; +* var sy = [ 1 ]; +* +* // Define the index offset: +* var ox = 1; +* var om = 0; +* +* var x = { +* 'dtype': 'float64', +* 'data': 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 ] ), +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* var mask = { +* 'dtype': 'uint8', +* 'data': new Uint8Array( [ 1, 0, 1, 0, 1, 0 ] ), +* 'shape': shape, +* 'strides': sm, +* 'offset': om, +* 'order': 'row-major' +* }; +* +* var y = { +* 'dtype': 'float64', +* 'data': new Float64Array( 3 ), +* 'shape': [ 3 ], +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major' +* }; +* +* mskfilter9d( x, mask, y ); +* +* console.log( y.data ); +* // => [ 2.0, 6.0, 10.0 ] +*/ +function mskfilter9d( x, mask, y ) { // eslint-disable-line max-statements + var xbuf; + var mbuf; + var ybuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dx6; + var dx7; + var dx8; + var dm0; + var dm1; + var dm2; + var dm3; + var dm4; + var dm5; + var dm6; + var dm7; + var dm8; + var dy0; + var S0; + var S1; + var S2; + var S3; + var S4; + var S5; + var S6; + var S7; + var S8; + var sh; + var sm; + var sx; + var ix; + var im; + var iy; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + var i7; + var i8; + + // Extract loop variables: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + sm = mask.strides; + if ( x.order === 'row-major' ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 8 ]; + S1 = sh[ 7 ]; + S2 = sh[ 6 ]; + S3 = sh[ 5 ]; + S4 = sh[ 4 ]; + S5 = sh[ 3 ]; + S6 = sh[ 2 ]; + S7 = sh[ 1 ]; + S8 = sh[ 0 ]; + dx0 = sx[ 8 ]; // offset increment for innermost loop + dx1 = sx[ 7 ] - ( S0*sx[8] ); + dx2 = sx[ 6 ] - ( S1*sx[7] ); + dx3 = sx[ 5 ] - ( S2*sx[6] ); + dx4 = sx[ 4 ] - ( S3*sx[5] ); + dx5 = sx[ 3 ] - ( S4*sx[4] ); + dx6 = sx[ 2 ] - ( S5*sx[3] ); + dx7 = sx[ 1 ] - ( S6*sx[2] ); + dx8 = sx[ 0 ] - ( S7*sx[1] ); // offset increment for outermost loop + dm0 = sm[ 8 ]; + dm1 = sm[ 7 ] - ( S0*sm[8] ); + dm2 = sm[ 6 ] - ( S1*sm[7] ); + dm3 = sm[ 5 ] - ( S2*sm[6] ); + dm4 = sm[ 4 ] - ( S3*sm[5] ); + dm5 = sm[ 3 ] - ( S4*sm[4] ); + dm6 = sm[ 2 ] - ( S5*sm[3] ); + dm7 = sm[ 1 ] - ( S6*sm[2] ); + dm8 = sm[ 0 ] - ( S7*sm[1] ); + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + S2 = sh[ 2 ]; + S3 = sh[ 3 ]; + S4 = sh[ 4 ]; + S5 = sh[ 5 ]; + S6 = sh[ 6 ]; + S7 = sh[ 7 ]; + S8 = sh[ 8 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); + dx2 = sx[ 2 ] - ( S1*sx[1] ); + dx3 = sx[ 3 ] - ( S2*sx[2] ); + dx4 = sx[ 4 ] - ( S3*sx[3] ); + dx5 = sx[ 5 ] - ( S4*sx[4] ); + dx6 = sx[ 6 ] - ( S5*sx[5] ); + dx7 = sx[ 7 ] - ( S6*sx[6] ); + dx8 = sx[ 8 ] - ( S7*sx[7] ); // offset increment for outermost loop + dm0 = sm[ 0 ]; + dm1 = sm[ 1 ] - ( S0*sm[0] ); + dm2 = sm[ 2 ] - ( S1*sm[1] ); + dm3 = sm[ 3 ] - ( S2*sm[2] ); + dm4 = sm[ 4 ] - ( S3*sm[3] ); + dm5 = sm[ 5 ] - ( S4*sm[4] ); + dm6 = sm[ 6 ] - ( S5*sm[5] ); + dm7 = sm[ 7 ] - ( S6*sm[6] ); + dm8 = sm[ 8 ] - ( S7*sm[7] ); + } + dy0 = y.strides[ 0 ]; + + // Set the pointers to the first indexed elements in the respective ndarrays... + ix = x.offset; + im = mask.offset; + iy = y.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + mbuf = mask.data; + ybuf = y.data; + + // Iterate over the ndarray dimensions... + for ( i8 = 0; i8 < S8; i8++ ) { + for ( i7 = 0; i7 < S7; i7++ ) { + for ( i6 = 0; i6 < S6; i6++ ) { + for ( i5 = 0; i5 < S5; i5++ ) { + for ( i4 = 0; i4 < S4; i4++ ) { + for ( i3 = 0; i3 < S3; i3++ ) { + for ( i2 = 0; i2 < S2; i2++ ) { + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( mbuf[ im ] ) { + ybuf[ iy ] = xbuf[ ix ]; + iy += dy0; + } + ix += dx0; + im += dm0; + } + ix += dx1; + im += dm1; + } + ix += dx2; + im += dm2; + } + ix += dx3; + im += dm3; + } + ix += dx4; + im += dm4; + } + ix += dx5; + im += dm5; + } + ix += dx6; + im += dm6; + } + ix += dx7; + im += dm7; + } + ix += dx8; + im += dm8; + } +} + + +// EXPORTS // + +module.exports = mskfilter9d; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_accessors.js new file mode 100644 index 00000000000..9ea86292a7b --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_accessors.js @@ -0,0 +1,289 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-depth */ + +'use strict'; + +// MAIN // + +/** +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {Object} mask - object containing mask ndarray meta data +* @param {Object} y - object containing output ndarray meta data +* @returns {void} +* +* @example +* var BooleanArray = require( '@stdlib/array/bool' ); +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* var realf = require( '@stdlib/complex/realf' ); +* var imagf = require( '@stdlib/complex/imagf' ); +* +* // Define the shape of the array: +* var shape = [ 1, 1, 1, 1, 1, 1, 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 2, 2, 2, 2, 2, 2, 2, 2, 1 ]; +* var sm = [ 2, 2, 2, 2, 2, 2, 2, 2, 1 ]; +* var sy = [ 1 ]; +* +* // Define the index offset: +* var ox = 0; +* var om = 0; +* +* // Define getters and setters: +* function getter( buf, idx ) { +* return buf.get( idx ); +* } +* +* function setter( buf, idx, value ) { +* buf.set( value, idx ); +* } +* +* var x = { +* 'dtype': 'complex64', +* 'data': new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ), +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* var mask = { +* 'dtype': 'bool', +* 'data': new BooleanArray( [ 1, 0, 1, 0 ] ), +* 'shape': shape, +* 'strides': sm, +* 'offset': om, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* var y = { +* 'dtype': 'complex64', +* 'data': new Complex64Array( 2 ), +* 'shape': [ 2 ], +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* mskfilter9d( x, mask, y ); +* +* var v = y.data.get( 0 ); +* // returns +* +* var re = realf( v ); +* // returns 1.0 +* +* var im = imagf( v ); +* // returns 2.0 +* +* v = y.data.get( 1 ); +* // returns +* +* re = realf( v ); +* // returns 5.0 +* +* im = imagf( v ); +* // returns 6.0 +*/ +function mskfilter9d( x, mask, y ) { // eslint-disable-line max-statements + var xbuf; + var mbuf; + var ybuf; + var xget; + var mget; + var yset; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dx6; + var dx7; + var dx8; + var dm0; + var dm1; + var dm2; + var dm3; + var dm4; + var dm5; + var dm6; + var dm7; + var dm8; + var dy0; + var S0; + var S1; + var S2; + var S3; + var S4; + var S5; + var S6; + var S7; + var S8; + var sh; + var sm; + var sx; + var ix; + var im; + var iy; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + var i7; + var i8; + + // Extract loop variables: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + sm = mask.strides; + if ( x.order === 'row-major' ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 8 ]; + S1 = sh[ 7 ]; + S2 = sh[ 6 ]; + S3 = sh[ 5 ]; + S4 = sh[ 4 ]; + S5 = sh[ 3 ]; + S6 = sh[ 2 ]; + S7 = sh[ 1 ]; + S8 = sh[ 0 ]; + dx0 = sx[ 8 ]; // offset increment for innermost loop + dx1 = sx[ 7 ] - ( S0*sx[8] ); + dx2 = sx[ 6 ] - ( S1*sx[7] ); + dx3 = sx[ 5 ] - ( S2*sx[6] ); + dx4 = sx[ 4 ] - ( S3*sx[5] ); + dx5 = sx[ 3 ] - ( S4*sx[4] ); + dx6 = sx[ 2 ] - ( S5*sx[3] ); + dx7 = sx[ 1 ] - ( S6*sx[2] ); + dx8 = sx[ 0 ] - ( S7*sx[1] ); // offset increment for outermost loop + dm0 = sm[ 8 ]; + dm1 = sm[ 7 ] - ( S0*sm[8] ); + dm2 = sm[ 6 ] - ( S1*sm[7] ); + dm3 = sm[ 5 ] - ( S2*sm[6] ); + dm4 = sm[ 4 ] - ( S3*sm[5] ); + dm5 = sm[ 3 ] - ( S4*sm[4] ); + dm6 = sm[ 2 ] - ( S5*sm[3] ); + dm7 = sm[ 1 ] - ( S6*sm[2] ); + dm8 = sm[ 0 ] - ( S7*sm[1] ); + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + S2 = sh[ 2 ]; + S3 = sh[ 3 ]; + S4 = sh[ 4 ]; + S5 = sh[ 5 ]; + S6 = sh[ 6 ]; + S7 = sh[ 7 ]; + S8 = sh[ 8 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); + dx2 = sx[ 2 ] - ( S1*sx[1] ); + dx3 = sx[ 3 ] - ( S2*sx[2] ); + dx4 = sx[ 4 ] - ( S3*sx[3] ); + dx5 = sx[ 5 ] - ( S4*sx[4] ); + dx6 = sx[ 6 ] - ( S5*sx[5] ); + dx7 = sx[ 7 ] - ( S6*sx[6] ); + dx8 = sx[ 8 ] - ( S7*sx[7] ); // offset increment for outermost loop + dm0 = sm[ 0 ]; + dm1 = sm[ 1 ] - ( S0*sm[0] ); + dm2 = sm[ 2 ] - ( S1*sm[1] ); + dm3 = sm[ 3 ] - ( S2*sm[2] ); + dm4 = sm[ 4 ] - ( S3*sm[3] ); + dm5 = sm[ 5 ] - ( S4*sm[4] ); + dm6 = sm[ 6 ] - ( S5*sm[5] ); + dm7 = sm[ 7 ] - ( S6*sm[6] ); + dm8 = sm[ 8 ] - ( S7*sm[7] ); + } + dy0 = y.strides[ 0 ]; + + // Set the pointers to the first indexed elements in the respective ndarrays... + ix = x.offset; + im = mask.offset; + iy = y.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + mbuf = mask.data; + ybuf = y.data; + + // Cache accessors: + xget = x.accessors[ 0 ]; + mget = mask.accessors[ 0 ]; + yset = y.accessors[ 1 ]; + + // Iterate over the ndarray dimensions... + for ( i8 = 0; i8 < S8; i8++ ) { + for ( i7 = 0; i7 < S7; i7++ ) { + for ( i6 = 0; i6 < S6; i6++ ) { + for ( i5 = 0; i5 < S5; i5++ ) { + for ( i4 = 0; i4 < S4; i4++ ) { + for ( i3 = 0; i3 < S3; i3++ ) { + for ( i2 = 0; i2 < S2; i2++ ) { + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( mget( mbuf, im ) ) { + yset( ybuf, iy, xget( xbuf, ix ) ); + iy += dy0; + } + ix += dx0; + im += dm0; + } + ix += dx1; + im += dm1; + } + ix += dx2; + im += dm2; + } + ix += dx3; + im += dm3; + } + ix += dx4; + im += dm4; + } + ix += dx5; + im += dm5; + } + ix += dx6; + im += dm6; + } + ix += dx7; + im += dm7; + } + ix += dx8; + im += dm8; + } +} + + +// EXPORTS // + +module.exports = mskfilter9d; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_blocked.js new file mode 100644 index 00000000000..3bb1f2d4e09 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_blocked.js @@ -0,0 +1,356 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-depth, max-len */ + +'use strict'; + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/unary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); + + +// MAIN // + +/** +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {Object} mask - object containing mask ndarray meta data +* @param {Object} y - object containing output ndarray meta data +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Uint8Array = require( '@stdlib/array/uint8' ); +* +* // Define the shape of the array: +* var shape = [ 1, 1, 1, 1, 1, 1, 3, 1, 2 ]; +* +* // Define the array strides: +* var sx = [ 12, 12, 12, 12, 12, 12, 4, 4, 1 ]; +* var sm = [ 6, 6, 6, 6, 6, 6, 2, 2, 1 ]; +* var sy = [ 1 ]; +* +* // Define the index offset: +* var ox = 1; +* var om = 0; +* +* var x = { +* 'dtype': 'float64', +* 'data': 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 ] ), +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* var mask = { +* 'dtype': 'uint8', +* 'data': new Uint8Array( [ 1, 0, 1, 0, 1, 0 ] ), +* 'shape': shape, +* 'strides': sm, +* 'offset': om, +* 'order': 'row-major' +* }; +* +* var y = { +* 'dtype': 'float64', +* 'data': new Float64Array( 3 ), +* 'shape': [ 3 ], +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major' +* }; +* +* blockedmskfilter9d( x, mask, y ); +* +* console.log( y.data ); +* // => [ 2.0, 6.0, 10.0 ] +*/ +function blockedmskfilter9d( x, mask, y ) { // eslint-disable-line max-statements, max-lines-per-function + var bsize; + var xbuf; + var mbuf; + var ybuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dx6; + var dx7; + var dx8; + var dm0; + var dm1; + var dm2; + var dm3; + var dm4; + var dm5; + var dm6; + var dm7; + var dm8; + var dy0; + var ox1; + var ox2; + var ox3; + var ox4; + var ox5; + var ox6; + var ox7; + var ox8; + var om1; + var om2; + var om3; + var om4; + var om5; + var om6; + var om7; + var om8; + var sh; + var s0; + var s1; + var s2; + var s3; + var s4; + var s5; + var s6; + var s7; + var s8; + var sx; + var sm; + var ox; + var om; + var ix; + var im; + var iy; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + var i7; + var i8; + var j0; + var j1; + var j2; + var j3; + var j4; + var j5; + var j6; + var j7; + var j8; + var o; + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides, mask.strides ); + sh = o.sh; + sx = o.sx; + sm = o.sy; + + // Determine the block size: + bsize = blockSize( x.dtype, mask.dtype ); + + // Cache the indices of the first indexed elements in the respective ndarrays... + ox = x.offset; + om = mask.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + mbuf = mask.data; + ybuf = y.data; + + // Cache offset increments for the innermost loop... + dx0 = sx[0]; + dm0 = sm[0]; + dy0 = y.strides[0]; + + iy = y.offset; + + // Iterate over blocks... + for ( j8 = sh[8]; j8 > 0; ) { + if ( j8 < bsize ) { + s8 = j8; + j8 = 0; + } else { + s8 = bsize; + j8 -= bsize; + } + ox8 = ox + ( j8*sx[8] ); + om8 = om + ( j8*sm[8] ); + for ( j7 = sh[7]; j7 > 0; ) { + if ( j7 < bsize ) { + s7 = j7; + j7 = 0; + } else { + s7 = bsize; + j7 -= bsize; + } + dx8 = sx[8] - ( s7*sx[7] ); + dm8 = sm[8] - ( s7*sm[7] ); + ox7 = ox8 + ( j7*sx[7] ); + om7 = om8 + ( j7*sm[7] ); + for ( j6 = sh[6]; j6 > 0; ) { + if ( j6 < bsize ) { + s6 = j6; + j6 = 0; + } else { + s6 = bsize; + j6 -= bsize; + } + dx7 = sx[7] - ( s6*sx[6] ); + dm7 = sm[7] - ( s6*sm[6] ); + ox6 = ox7 + ( j6*sx[6] ); + om6 = om7 + ( j6*sm[6] ); + for ( j5 = sh[5]; j5 > 0; ) { + if ( j5 < bsize ) { + s5 = j5; + j5 = 0; + } else { + s5 = bsize; + j5 -= bsize; + } + dx6 = sx[6] - ( s5*sx[5] ); + dm6 = sm[6] - ( s5*sm[5] ); + ox5 = ox6 + ( j5*sx[5] ); + om5 = om6 + ( j5*sm[5] ); + for ( j4 = sh[4]; j4 > 0; ) { + if ( j4 < bsize ) { + s4 = j4; + j4 = 0; + } else { + s4 = bsize; + j4 -= bsize; + } + dx5 = sx[5] - ( s4*sx[4] ); + dm5 = sm[5] - ( s4*sm[4] ); + ox4 = ox5 + ( j4*sx[4] ); + om4 = om5 + ( j4*sm[4] ); + for ( j3 = sh[3]; j3 > 0; ) { + if ( j3 < bsize ) { + s3 = j3; + j3 = 0; + } else { + s3 = bsize; + j3 -= bsize; + } + dx4 = sx[4] - ( s3*sx[3] ); + dm4 = sm[4] - ( s3*sm[3] ); + ox3 = ox4 + ( j3*sx[3] ); + om3 = om4 + ( j3*sm[3] ); + for ( j2 = sh[2]; j2 > 0; ) { + if ( j2 < bsize ) { + s2 = j2; + j2 = 0; + } else { + s2 = bsize; + j2 -= bsize; + } + dx3 = sx[3] - ( s2*sx[2] ); + dm3 = sm[3] - ( s2*sm[2] ); + ox2 = ox3 + ( j2*sx[2] ); + om2 = om3 + ( j2*sm[2] ); + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + dx2 = sx[2] - ( s1*sx[1] ); + dm2 = sm[2] - ( s1*sm[1] ); + ox1 = ox2 + ( j1*sx[1] ); + om1 = om2 + ( j1*sm[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute index offsets for the first input and output ndarray elements in the current block... + ix = ox1 + ( j0*sx[0] ); + im = om1 + ( j0*sm[0] ); + + // Compute loop offset increments... + dx1 = sx[1] - ( s0*sx[0] ); + dm1 = sm[1] - ( s0*sm[0] ); + + // Iterate over the ndarray dimensions... + for ( i8 = 0; i8 < s8; i8++ ) { + for ( i7 = 0; i7 < s7; i7++ ) { + for ( i6 = 0; i6 < s6; i6++ ) { + for ( i5 = 0; i5 < s5; i5++ ) { + for ( i4 = 0; i4 < s4; i4++ ) { + for ( i3 = 0; i3 < s3; i3++ ) { + for ( i2 = 0; i2 < s2; i2++ ) { + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( mbuf[ im ] ) { + ybuf[ iy ] = xbuf[ ix ]; + iy += dy0; + } + ix += dx0; + im += dm0; + } + ix += dx1; + im += dm1; + } + ix += dx2; + im += dm2; + } + ix += dx3; + im += dm3; + } + ix += dx4; + im += dm4; + } + ix += dx5; + im += dm5; + } + ix += dx6; + im += dm6; + } + ix += dx7; + im += dm7; + } + ix += dx8; + im += dm8; + } + } + } + } + } + } + } + } + } + } +} + + +// EXPORTS // + +module.exports = blockedmskfilter9d; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_blocked_accessors.js new file mode 100644 index 00000000000..05031eb36da --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_blocked_accessors.js @@ -0,0 +1,394 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-depth, max-len */ + +'use strict'; + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/unary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); + + +// MAIN // + +/** +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {Object} mask - object containing mask ndarray meta data +* @param {Object} y - object containing output ndarray meta data +* @returns {void} +* +* @example +* var BooleanArray = require( '@stdlib/array/bool' ); +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* var realf = require( '@stdlib/complex/realf' ); +* var imagf = require( '@stdlib/complex/imagf' ); +* +* // Define the shape of the array: +* var shape = [ 1, 1, 1, 1, 1, 1, 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 2, 2, 2, 2, 2, 2, 2, 2, 1 ]; +* var sm = [ 2, 2, 2, 2, 2, 2, 2, 2, 1 ]; +* var sy = [ 1 ]; +* +* // Define the index offset: +* var ox = 0; +* var om = 0; +* +* // Define getters and setters: +* function getter( buf, idx ) { +* return buf.get( idx ); +* } +* +* function setter( buf, idx, value ) { +* buf.set( value, idx ); +* } +* +* var x = { +* 'dtype': 'complex64', +* 'data': new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ), +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* var mask = { +* 'dtype': 'bool', +* 'data': new BooleanArray( [ 1, 0, 1, 0 ] ), +* 'shape': shape, +* 'strides': sm, +* 'offset': om, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* var y = { +* 'dtype': 'complex64', +* 'data': new Complex64Array( 2 ), +* 'shape': [ 2 ], +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* blockedmskfilter9d( x, mask, y ); +* +* var v = y.data.get( 0 ); +* // returns +* +* var re = realf( v ); +* // returns 1.0 +* +* var im = imagf( v ); +* // returns 2.0 +* +* v = y.data.get( 1 ); +* // returns +* +* re = realf( v ); +* // returns 5.0 +* +* im = imagf( v ); +* // returns 6.0 +*/ +function blockedmskfilter9d( x, mask, y ) { // eslint-disable-line max-statements, max-lines-per-function + var bsize; + var xbuf; + var mbuf; + var ybuf; + var xget; + var mget; + var yset; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dx6; + var dx7; + var dx8; + var dm0; + var dm1; + var dm2; + var dm3; + var dm4; + var dm5; + var dm6; + var dm7; + var dm8; + var dy0; + var ox1; + var ox2; + var ox3; + var ox4; + var ox5; + var ox6; + var ox7; + var ox8; + var om1; + var om2; + var om3; + var om4; + var om5; + var om6; + var om7; + var om8; + var sh; + var s0; + var s1; + var s2; + var s3; + var s4; + var s5; + var s6; + var s7; + var s8; + var sx; + var sm; + var ox; + var om; + var ix; + var im; + var iy; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + var i7; + var i8; + var j0; + var j1; + var j2; + var j3; + var j4; + var j5; + var j6; + var j7; + var j8; + var o; + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides, mask.strides ); + sh = o.sh; + sx = o.sx; + sm = o.sy; + + // Determine the block size: + bsize = blockSize( x.dtype, mask.dtype ); + + // Cache the indices of the first indexed elements in the respective ndarrays... + ox = x.offset; + om = mask.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + mbuf = mask.data; + ybuf = y.data; + + // Cache offset increments for the innermost loop... + dx0 = sx[0]; + dm0 = sm[0]; + dy0 = y.strides[0]; + + iy = y.offset; + + // Cache accessors: + xget = x.accessors[ 0 ]; + mget = mask.accessors[ 0 ]; + yset = y.accessors[ 1 ]; + + // Iterate over blocks... + for ( j8 = sh[8]; j8 > 0; ) { + if ( j8 < bsize ) { + s8 = j8; + j8 = 0; + } else { + s8 = bsize; + j8 -= bsize; + } + ox8 = ox + ( j8*sx[8] ); + om8 = om + ( j8*sm[8] ); + for ( j7 = sh[7]; j7 > 0; ) { + if ( j7 < bsize ) { + s7 = j7; + j7 = 0; + } else { + s7 = bsize; + j7 -= bsize; + } + dx8 = sx[8] - ( s7*sx[7] ); + dm8 = sm[8] - ( s7*sm[7] ); + ox7 = ox8 + ( j7*sx[7] ); + om7 = om8 + ( j7*sm[7] ); + for ( j6 = sh[6]; j6 > 0; ) { + if ( j6 < bsize ) { + s6 = j6; + j6 = 0; + } else { + s6 = bsize; + j6 -= bsize; + } + dx7 = sx[7] - ( s6*sx[6] ); + dm7 = sm[7] - ( s6*sm[6] ); + ox6 = ox7 + ( j6*sx[6] ); + om6 = om7 + ( j6*sm[6] ); + for ( j5 = sh[5]; j5 > 0; ) { + if ( j5 < bsize ) { + s5 = j5; + j5 = 0; + } else { + s5 = bsize; + j5 -= bsize; + } + dx6 = sx[6] - ( s5*sx[5] ); + dm6 = sm[6] - ( s5*sm[5] ); + ox5 = ox6 + ( j5*sx[5] ); + om5 = om6 + ( j5*sm[5] ); + for ( j4 = sh[4]; j4 > 0; ) { + if ( j4 < bsize ) { + s4 = j4; + j4 = 0; + } else { + s4 = bsize; + j4 -= bsize; + } + dx5 = sx[5] - ( s4*sx[4] ); + dm5 = sm[5] - ( s4*sm[4] ); + ox4 = ox5 + ( j4*sx[4] ); + om4 = om5 + ( j4*sm[4] ); + for ( j3 = sh[3]; j3 > 0; ) { + if ( j3 < bsize ) { + s3 = j3; + j3 = 0; + } else { + s3 = bsize; + j3 -= bsize; + } + dx4 = sx[4] - ( s3*sx[3] ); + dm4 = sm[4] - ( s3*sm[3] ); + ox3 = ox4 + ( j3*sx[3] ); + om3 = om4 + ( j3*sm[3] ); + for ( j2 = sh[2]; j2 > 0; ) { + if ( j2 < bsize ) { + s2 = j2; + j2 = 0; + } else { + s2 = bsize; + j2 -= bsize; + } + dx3 = sx[3] - ( s2*sx[2] ); + dm3 = sm[3] - ( s2*sm[2] ); + ox2 = ox3 + ( j2*sx[2] ); + om2 = om3 + ( j2*sm[2] ); + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + dx2 = sx[2] - ( s1*sx[1] ); + dm2 = sm[2] - ( s1*sm[1] ); + ox1 = ox2 + ( j1*sx[1] ); + om1 = om2 + ( j1*sm[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute index offsets for the first input and output ndarray elements in the current block... + ix = ox1 + ( j0*sx[0] ); + im = om1 + ( j0*sm[0] ); + + // Compute loop offset increments... + dx1 = sx[1] - ( s0*sx[0] ); + dm1 = sm[1] - ( s0*sm[0] ); + + // Iterate over the ndarray dimensions... + for ( i8 = 0; i8 < s8; i8++ ) { + for ( i7 = 0; i7 < s7; i7++ ) { + for ( i6 = 0; i6 < s6; i6++ ) { + for ( i5 = 0; i5 < s5; i5++ ) { + for ( i4 = 0; i4 < s4; i4++ ) { + for ( i3 = 0; i3 < s3; i3++ ) { + for ( i2 = 0; i2 < s2; i2++ ) { + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( mget( mbuf, im ) ) { + yset( ybuf, iy, xget( xbuf, ix ) ); + iy += dy0; + } + ix += dx0; + im += dm0; + } + ix += dx1; + im += dm1; + } + ix += dx2; + im += dm2; + } + ix += dx3; + im += dm3; + } + ix += dx4; + im += dm4; + } + ix += dx5; + im += dm5; + } + ix += dx6; + im += dm6; + } + ix += dx7; + im += dm7; + } + ix += dx8; + im += dm8; + } + } + } + } + } + } + } + } + } + } +} + + +// EXPORTS // + +module.exports = blockedmskfilter9d; From 121db5af59567bfe396cf9d1cb6632d11b81578e Mon Sep 17 00:00:00 2001 From: Jaysukh-409 Date: Mon, 5 Aug 2024 20:08:56 +0530 Subject: [PATCH 17/34] feat: add kernels for 10d ndarray --- .../@stdlib/ndarray/base/mskfilter/lib/10d.js | 265 +++++++++++ .../base/mskfilter/lib/10d_accessors.js | 303 +++++++++++++ .../ndarray/base/mskfilter/lib/10d_blocked.js | 380 ++++++++++++++++ .../mskfilter/lib/10d_blocked_accessors.js | 418 ++++++++++++++++++ .../ndarray/base/mskfilter/lib/main.js | 66 ++- 5 files changed, 1428 insertions(+), 4 deletions(-) create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_blocked.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_blocked_accessors.js diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d.js new file mode 100644 index 00000000000..2318dd0381a --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d.js @@ -0,0 +1,265 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-depth */ + +'use strict'; + +// MAIN // + +/** +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {Object} mask - object containing mask ndarray meta data +* @param {Object} y - object containing output ndarray meta data +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Uint8Array = require( '@stdlib/array/uint8' ); +* +* // Define the shape of the array: +* var shape = [ 1, 1, 1, 1, 1, 1, 1, 3, 1, 2 ]; +* +* // Define the array strides: +* var sx = [ 12, 12, 12, 12, 12, 12, 12, 4, 4, 1 ]; +* var sm = [ 6, 6, 6, 6, 6, 6, 6, 2, 2, 1 ]; +* var sy = [ 1 ]; +* +* // Define the index offset: +* var ox = 1; +* var om = 0; +* +* var x = { +* 'dtype': 'float64', +* 'data': 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 ] ), +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* var mask = { +* 'dtype': 'uint8', +* 'data': new Uint8Array( [ 1, 0, 1, 0, 1, 0 ] ), +* 'shape': shape, +* 'strides': sm, +* 'offset': om, +* 'order': 'row-major' +* }; +* +* var y = { +* 'dtype': 'float64', +* 'data': new Float64Array( 3 ), +* 'shape': [ 3 ], +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major' +* }; +* +* mskfilter10d( x, mask, y ); +* +* console.log( y.data ); +* // => [ 2.0, 6.0, 10.0 ] +*/ +function mskfilter10d( x, mask, y ) { // eslint-disable-line max-statements + var xbuf; + var mbuf; + var ybuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dx6; + var dx7; + var dx8; + var dx9; + var dm0; + var dm1; + var dm2; + var dm3; + var dm4; + var dm5; + var dm6; + var dm7; + var dm8; + var dm9; + var dy0; + var S0; + var S1; + var S2; + var S3; + var S4; + var S5; + var S6; + var S7; + var S8; + var S9; + var sh; + var sm; + var sx; + var ix; + var im; + var iy; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + var i7; + var i8; + var i9; + + // Extract loop variables: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + sm = mask.strides; + if ( x.order === 'row-major' ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 9 ]; + S1 = sh[ 8 ]; + S2 = sh[ 7 ]; + S3 = sh[ 6 ]; + S4 = sh[ 5 ]; + S5 = sh[ 4 ]; + S6 = sh[ 3 ]; + S7 = sh[ 2 ]; + S8 = sh[ 1 ]; + S9 = sh[ 0 ]; + dx0 = sx[ 9 ]; // offset increment for innermost loop + dx1 = sx[ 8 ] - ( S0*sx[9] ); + dx2 = sx[ 7 ] - ( S1*sx[8] ); + dx3 = sx[ 6 ] - ( S2*sx[7] ); + dx4 = sx[ 5 ] - ( S3*sx[6] ); + dx5 = sx[ 4 ] - ( S4*sx[5] ); + dx6 = sx[ 3 ] - ( S5*sx[4] ); + dx7 = sx[ 2 ] - ( S6*sx[3] ); + dx8 = sx[ 1 ] - ( S7*sx[2] ); + dx9 = sx[ 0 ] - ( S8*sx[1] ); // offset increment for outermost loop + dm0 = sm[ 9 ]; + dm1 = sm[ 8 ] - ( S0*sm[9] ); + dm2 = sm[ 7 ] - ( S1*sm[8] ); + dm3 = sm[ 6 ] - ( S2*sm[7] ); + dm4 = sm[ 5 ] - ( S3*sm[6] ); + dm5 = sm[ 4 ] - ( S4*sm[5] ); + dm6 = sm[ 3 ] - ( S5*sm[4] ); + dm7 = sm[ 2 ] - ( S6*sm[3] ); + dm8 = sm[ 1 ] - ( S7*sm[2] ); + dm9 = sm[ 0 ] - ( S8*sm[1] ); + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + S2 = sh[ 2 ]; + S3 = sh[ 3 ]; + S4 = sh[ 4 ]; + S5 = sh[ 5 ]; + S6 = sh[ 6 ]; + S7 = sh[ 7 ]; + S8 = sh[ 8 ]; + S9 = sh[ 9 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); + dx2 = sx[ 2 ] - ( S1*sx[1] ); + dx3 = sx[ 3 ] - ( S2*sx[2] ); + dx4 = sx[ 4 ] - ( S3*sx[3] ); + dx5 = sx[ 5 ] - ( S4*sx[4] ); + dx6 = sx[ 6 ] - ( S5*sx[5] ); + dx7 = sx[ 7 ] - ( S6*sx[6] ); + dx8 = sx[ 8 ] - ( S7*sx[7] ); + dx9 = sx[ 9 ] - ( S8*sx[8] ); // offset increment for outermost loop + dm0 = sm[ 0 ]; + dm1 = sm[ 1 ] - ( S0*sm[0] ); + dm2 = sm[ 2 ] - ( S1*sm[1] ); + dm3 = sm[ 3 ] - ( S2*sm[2] ); + dm4 = sm[ 4 ] - ( S3*sm[3] ); + dm5 = sm[ 5 ] - ( S4*sm[4] ); + dm6 = sm[ 6 ] - ( S5*sm[5] ); + dm7 = sm[ 7 ] - ( S6*sm[6] ); + dm8 = sm[ 8 ] - ( S7*sm[7] ); + dm9 = sm[ 9 ] - ( S8*sm[8] ); + } + dy0 = y.strides[ 0 ]; + + // Set the pointers to the first indexed elements in the respective ndarrays... + ix = x.offset; + im = mask.offset; + iy = y.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + mbuf = mask.data; + ybuf = y.data; + + // Iterate over the ndarray dimensions... + for ( i9 = 0; i9 < S9; i9++ ) { + for ( i8 = 0; i8 < S8; i8++ ) { + for ( i7 = 0; i7 < S7; i7++ ) { + for ( i6 = 0; i6 < S6; i6++ ) { + for ( i5 = 0; i5 < S5; i5++ ) { + for ( i4 = 0; i4 < S4; i4++ ) { + for ( i3 = 0; i3 < S3; i3++ ) { + for ( i2 = 0; i2 < S2; i2++ ) { + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( mbuf[ im ] ) { + ybuf[ iy ] = xbuf[ ix ]; + iy += dy0; + } + ix += dx0; + im += dm0; + } + ix += dx1; + im += dm1; + } + ix += dx2; + im += dm2; + } + ix += dx3; + im += dm3; + } + ix += dx4; + im += dm4; + } + ix += dx5; + im += dm5; + } + ix += dx6; + im += dm6; + } + ix += dx7; + im += dm7; + } + ix += dx8; + im += dm8; + } + ix += dx9; + im += dm9; + } +} + + +// EXPORTS // + +module.exports = mskfilter10d; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_accessors.js new file mode 100644 index 00000000000..dea496f94a3 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_accessors.js @@ -0,0 +1,303 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-depth, max-len */ + +'use strict'; + +// MAIN // + +/** +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {Object} mask - object containing mask ndarray meta data +* @param {Object} y - object containing output ndarray meta data +* @returns {void} +* +* @example +* var BooleanArray = require( '@stdlib/array/bool' ); +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* var realf = require( '@stdlib/complex/realf' ); +* var imagf = require( '@stdlib/complex/imagf' ); +* +* // Define the shape of the array: +* var shape = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 2, 2, 2, 2, 2, 2, 2, 2, 2, 1 ]; +* var sm = [ 2, 2, 2, 2, 2, 2, 2, 2, 2, 1 ]; +* var sy = [ 1 ]; +* +* // Define the index offset: +* var ox = 0; +* var om = 0; +* +* // Define getters and setters: +* function getter( buf, idx ) { +* return buf.get( idx ); +* } +* +* function setter( buf, idx, value ) { +* buf.set( value, idx ); +* } +* +* var x = { +* 'dtype': 'complex64', +* 'data': new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ), +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* var mask = { +* 'dtype': 'bool', +* 'data': new BooleanArray( [ 1, 0, 1, 0 ] ), +* 'shape': shape, +* 'strides': sm, +* 'offset': om, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* var y = { +* 'dtype': 'complex64', +* 'data': new Complex64Array( 2 ), +* 'shape': [ 2 ], +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* mskfilter10d( x, mask, y ); +* +* var v = y.data.get( 0 ); +* // returns +* +* var re = realf( v ); +* // returns 1.0 +* +* var im = imagf( v ); +* // returns 2.0 +* +* v = y.data.get( 1 ); +* // returns +* +* re = realf( v ); +* // returns 5.0 +* +* im = imagf( v ); +* // returns 6.0 +*/ +function mskfilter10d( x, mask, y ) { // eslint-disable-line max-statements + var xbuf; + var mbuf; + var ybuf; + var xget; + var mget; + var yset; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dx6; + var dx7; + var dx8; + var dx9; + var dm0; + var dm1; + var dm2; + var dm3; + var dm4; + var dm5; + var dm6; + var dm7; + var dm8; + var dm9; + var dy0; + var S0; + var S1; + var S2; + var S3; + var S4; + var S5; + var S6; + var S7; + var S8; + var S9; + var sh; + var sm; + var sx; + var ix; + var im; + var iy; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + var i7; + var i8; + var i9; + + // Extract loop variables: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + sm = mask.strides; + if ( x.order === 'row-major' ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 9 ]; + S1 = sh[ 8 ]; + S2 = sh[ 7 ]; + S3 = sh[ 6 ]; + S4 = sh[ 5 ]; + S5 = sh[ 4 ]; + S6 = sh[ 3 ]; + S7 = sh[ 2 ]; + S8 = sh[ 1 ]; + S9 = sh[ 0 ]; + dx0 = sx[ 9 ]; // offset increment for innermost loop + dx1 = sx[ 8 ] - ( S0*sx[9] ); + dx2 = sx[ 7 ] - ( S1*sx[8] ); + dx3 = sx[ 6 ] - ( S2*sx[7] ); + dx4 = sx[ 5 ] - ( S3*sx[6] ); + dx5 = sx[ 4 ] - ( S4*sx[5] ); + dx6 = sx[ 3 ] - ( S5*sx[4] ); + dx7 = sx[ 2 ] - ( S6*sx[3] ); + dx8 = sx[ 1 ] - ( S7*sx[2] ); + dx9 = sx[ 0 ] - ( S8*sx[1] ); // offset increment for outermost loop + dm0 = sm[ 9 ]; + dm1 = sm[ 8 ] - ( S0*sm[9] ); + dm2 = sm[ 7 ] - ( S1*sm[8] ); + dm3 = sm[ 6 ] - ( S2*sm[7] ); + dm4 = sm[ 5 ] - ( S3*sm[6] ); + dm5 = sm[ 4 ] - ( S4*sm[5] ); + dm6 = sm[ 3 ] - ( S5*sm[4] ); + dm7 = sm[ 2 ] - ( S6*sm[3] ); + dm8 = sm[ 1 ] - ( S7*sm[2] ); + dm9 = sm[ 0 ] - ( S8*sm[1] ); + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + S2 = sh[ 2 ]; + S3 = sh[ 3 ]; + S4 = sh[ 4 ]; + S5 = sh[ 5 ]; + S6 = sh[ 6 ]; + S7 = sh[ 7 ]; + S8 = sh[ 8 ]; + S9 = sh[ 9 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); + dx2 = sx[ 2 ] - ( S1*sx[1] ); + dx3 = sx[ 3 ] - ( S2*sx[2] ); + dx4 = sx[ 4 ] - ( S3*sx[3] ); + dx5 = sx[ 5 ] - ( S4*sx[4] ); + dx6 = sx[ 6 ] - ( S5*sx[5] ); + dx7 = sx[ 7 ] - ( S6*sx[6] ); + dx8 = sx[ 8 ] - ( S7*sx[7] ); + dx9 = sx[ 9 ] - ( S8*sx[8] ); // offset increment for outermost loop + dm0 = sm[ 0 ]; + dm1 = sm[ 1 ] - ( S0*sm[0] ); + dm2 = sm[ 2 ] - ( S1*sm[1] ); + dm3 = sm[ 3 ] - ( S2*sm[2] ); + dm4 = sm[ 4 ] - ( S3*sm[3] ); + dm5 = sm[ 5 ] - ( S4*sm[4] ); + dm6 = sm[ 6 ] - ( S5*sm[5] ); + dm7 = sm[ 7 ] - ( S6*sm[6] ); + dm8 = sm[ 8 ] - ( S7*sm[7] ); + dm9 = sm[ 9 ] - ( S8*sm[8] ); + } + dy0 = y.strides[ 0 ]; + + // Set the pointers to the first indexed elements in the respective ndarrays... + ix = x.offset; + im = mask.offset; + iy = y.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + mbuf = mask.data; + ybuf = y.data; + + // Cache accessors: + xget = x.accessors[ 0 ]; + mget = mask.accessors[ 0 ]; + yset = y.accessors[ 1 ]; + + // Iterate over the ndarray dimensions... + for ( i9 = 0; i9 < S9; i9++ ) { + for ( i8 = 0; i8 < S8; i8++ ) { + for ( i7 = 0; i7 < S7; i7++ ) { + for ( i6 = 0; i6 < S6; i6++ ) { + for ( i5 = 0; i5 < S5; i5++ ) { + for ( i4 = 0; i4 < S4; i4++ ) { + for ( i3 = 0; i3 < S3; i3++ ) { + for ( i2 = 0; i2 < S2; i2++ ) { + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( mget( mbuf, im ) ) { + yset( ybuf, iy, xget( xbuf, ix ) ); + iy += dy0; + } + ix += dx0; + im += dm0; + } + ix += dx1; + im += dm1; + } + ix += dx2; + im += dm2; + } + ix += dx3; + im += dm3; + } + ix += dx4; + im += dm4; + } + ix += dx5; + im += dm5; + } + ix += dx6; + im += dm6; + } + ix += dx7; + im += dm7; + } + ix += dx8; + im += dm8; + } + ix += dx9; + im += dm9; + } +} + + +// EXPORTS // + +module.exports = mskfilter10d; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_blocked.js new file mode 100644 index 00000000000..0c6543290e1 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_blocked.js @@ -0,0 +1,380 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-depth, max-len */ + +'use strict'; + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/unary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); + + +// MAIN // + +/** +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {Object} mask - object containing mask ndarray meta data +* @param {Object} y - object containing output ndarray meta data +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Uint8Array = require( '@stdlib/array/uint8' ); +* +* // Define the shape of the array: +* var shape = [ 1, 1, 1, 1, 1, 1, 1, 3, 1, 2 ]; +* +* // Define the array strides: +* var sx = [ 12, 12, 12, 12, 12, 12, 12, 4, 4, 1 ]; +* var sm = [ 6, 6, 6, 6, 6, 6, 6, 2, 2, 1 ]; +* var sy = [ 1 ]; +* +* // Define the index offset: +* var ox = 1; +* var om = 0; +* +* var x = { +* 'dtype': 'float64', +* 'data': 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 ] ), +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* var mask = { +* 'dtype': 'uint8', +* 'data': new Uint8Array( [ 1, 0, 1, 0, 1, 0 ] ), +* 'shape': shape, +* 'strides': sm, +* 'offset': om, +* 'order': 'row-major' +* }; +* +* var y = { +* 'dtype': 'float64', +* 'data': new Float64Array( 3 ), +* 'shape': [ 3 ], +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major' +* }; +* +* blockedmskfilter10d( x, mask, y ); +* +* console.log( y.data ); +* // => [ 2.0, 6.0, 10.0 ] +*/ +function blockedmskfilter10d( x, mask, y ) { // eslint-disable-line max-statements, max-lines-per-function + var bsize; + var xbuf; + var mbuf; + var ybuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dx6; + var dx7; + var dx8; + var dx9; + var dm0; + var dm1; + var dm2; + var dm3; + var dm4; + var dm5; + var dm6; + var dm7; + var dm8; + var dm9; + var dy0; + var ox1; + var ox2; + var ox3; + var ox4; + var ox5; + var ox6; + var ox7; + var ox8; + var ox9; + var om1; + var om2; + var om3; + var om4; + var om5; + var om6; + var om7; + var om8; + var om9; + var sh; + var s0; + var s1; + var s2; + var s3; + var s4; + var s5; + var s6; + var s7; + var s8; + var s9; + var sx; + var sm; + var ox; + var om; + var ix; + var im; + var iy; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + var i7; + var i8; + var i9; + var j0; + var j1; + var j2; + var j3; + var j4; + var j5; + var j6; + var j7; + var j8; + var j9; + var o; + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides, mask.strides ); + sh = o.sh; + sx = o.sx; + sm = o.sy; + + // Determine the block size: + bsize = blockSize( x.dtype, mask.dtype ); + + // Cache the indices of the first indexed elements in the respective ndarrays... + ox = x.offset; + om = mask.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + mbuf = mask.data; + ybuf = y.data; + + // Cache offset increments for the innermost loop... + dx0 = sx[0]; + dm0 = sm[0]; + dy0 = y.strides[0]; + + iy = y.offset; + + // Iterate over blocks... + for ( j9 = sh[9]; j9 > 0; ) { + if ( j9 < bsize ) { + s9 = j9; + j9 = 0; + } else { + s9 = bsize; + j9 -= bsize; + } + ox9 = ox + ( j9*sx[9] ); + om9 = om + ( j9*sm[9] ); + for ( j8 = sh[8]; j8 > 0; ) { + if ( j8 < bsize ) { + s8 = j8; + j8 = 0; + } else { + s8 = bsize; + j8 -= bsize; + } + dx9 = sx[9] - ( s8*sx[8] ); + dm9 = sm[9] - ( s8*sm[8] ); + ox8 = ox9 + ( j8*sx[8] ); + om8 = om9 + ( j8*sm[8] ); + for ( j7 = sh[7]; j7 > 0; ) { + if ( j7 < bsize ) { + s7 = j7; + j7 = 0; + } else { + s7 = bsize; + j7 -= bsize; + } + dx8 = sx[8] - ( s7*sx[7] ); + dm8 = sm[8] - ( s7*sm[7] ); + ox7 = ox8 + ( j7*sx[7] ); + om7 = om8 + ( j7*sm[7] ); + for ( j6 = sh[6]; j6 > 0; ) { + if ( j6 < bsize ) { + s6 = j6; + j6 = 0; + } else { + s6 = bsize; + j6 -= bsize; + } + dx7 = sx[7] - ( s6*sx[6] ); + dm7 = sm[7] - ( s6*sm[6] ); + ox6 = ox7 + ( j6*sx[6] ); + om6 = om7 + ( j6*sm[6] ); + for ( j5 = sh[5]; j5 > 0; ) { + if ( j5 < bsize ) { + s5 = j5; + j5 = 0; + } else { + s5 = bsize; + j5 -= bsize; + } + dx6 = sx[6] - ( s5*sx[5] ); + dm6 = sm[6] - ( s5*sm[5] ); + ox5 = ox6 + ( j5*sx[5] ); + om5 = om6 + ( j5*sm[5] ); + for ( j4 = sh[4]; j4 > 0; ) { + if ( j4 < bsize ) { + s4 = j4; + j4 = 0; + } else { + s4 = bsize; + j4 -= bsize; + } + dx5 = sx[5] - ( s4*sx[4] ); + dm5 = sm[5] - ( s4*sm[4] ); + ox4 = ox5 + ( j4*sx[4] ); + om4 = om5 + ( j4*sm[4] ); + for ( j3 = sh[3]; j3 > 0; ) { + if ( j3 < bsize ) { + s3 = j3; + j3 = 0; + } else { + s3 = bsize; + j3 -= bsize; + } + dx4 = sx[4] - ( s3*sx[3] ); + dm4 = sm[4] - ( s3*sm[3] ); + ox3 = ox4 + ( j3*sx[3] ); + om3 = om4 + ( j3*sm[3] ); + for ( j2 = sh[2]; j2 > 0; ) { + if ( j2 < bsize ) { + s2 = j2; + j2 = 0; + } else { + s2 = bsize; + j2 -= bsize; + } + dx3 = sx[3] - ( s2*sx[2] ); + dm3 = sm[3] - ( s2*sm[2] ); + ox2 = ox3 + ( j2*sx[2] ); + om2 = om3 + ( j2*sm[2] ); + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + dx2 = sx[2] - ( s1*sx[1] ); + dm2 = sm[2] - ( s1*sm[1] ); + ox1 = ox2 + ( j1*sx[1] ); + om1 = om2 + ( j1*sm[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute index offsets for the first input and output ndarray elements in the current block... + ix = ox1 + ( j0*sx[0] ); + im = om1 + ( j0*sm[0] ); + + // Compute loop offset increments... + dx1 = sx[1] - ( s0*sx[0] ); + dm1 = sm[1] - ( s0*sm[0] ); + + // Iterate over the ndarray dimensions... + for ( i9 = 0; i9 < s9; i9++ ) { + for ( i8 = 0; i8 < s8; i8++ ) { + for ( i7 = 0; i7 < s7; i7++ ) { + for ( i6 = 0; i6 < s6; i6++ ) { + for ( i5 = 0; i5 < s5; i5++ ) { + for ( i4 = 0; i4 < s4; i4++ ) { + for ( i3 = 0; i3 < s3; i3++ ) { + for ( i2 = 0; i2 < s2; i2++ ) { + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( mbuf[ im ] ) { + ybuf[ iy ] = xbuf[ ix ]; + iy += dy0; + } + ix += dx0; + im += dm0; + } + ix += dx1; + im += dm1; + } + ix += dx2; + im += dm2; + } + ix += dx3; + im += dm3; + } + ix += dx4; + im += dm4; + } + ix += dx5; + im += dm5; + } + ix += dx6; + im += dm6; + } + ix += dx7; + im += dm7; + } + ix += dx8; + im += dm8; + } + ix += dx9; + im += dm9; + } + } + } + } + } + } + } + } + } + } + } +} + + +// EXPORTS // + +module.exports = blockedmskfilter10d; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_blocked_accessors.js new file mode 100644 index 00000000000..b0e2c3c9c05 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_blocked_accessors.js @@ -0,0 +1,418 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-depth, max-len */ + +'use strict'; + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/unary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); + + +// MAIN // + +/** +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {Object} mask - object containing mask ndarray meta data +* @param {Object} y - object containing output ndarray meta data +* @returns {void} +* +* @example +* var BooleanArray = require( '@stdlib/array/bool' ); +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* var realf = require( '@stdlib/complex/realf' ); +* var imagf = require( '@stdlib/complex/imagf' ); +* +* // Define the shape of the array: +* var shape = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 2, 2, 2, 2, 2, 2, 2, 2, 2, 1 ]; +* var sm = [ 2, 2, 2, 2, 2, 2, 2, 2, 2, 1 ]; +* var sy = [ 1 ]; +* +* // Define the index offset: +* var ox = 0; +* var om = 0; +* +* // Define getters and setters: +* function getter( buf, idx ) { +* return buf.get( idx ); +* } +* +* function setter( buf, idx, value ) { +* buf.set( value, idx ); +* } +* +* var x = { +* 'dtype': 'complex64', +* 'data': new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ), +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* var mask = { +* 'dtype': 'bool', +* 'data': new BooleanArray( [ 1, 0, 1, 0 ] ), +* 'shape': shape, +* 'strides': sm, +* 'offset': om, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* var y = { +* 'dtype': 'complex64', +* 'data': new Complex64Array( 2 ), +* 'shape': [ 2 ], +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major', +* 'accessors': [ getter, setter ] +* }; +* +* blockedmskfilter10d( x, mask, y ); +* +* var v = y.data.get( 0 ); +* // returns +* +* var re = realf( v ); +* // returns 1.0 +* +* var im = imagf( v ); +* // returns 2.0 +* +* v = y.data.get( 1 ); +* // returns +* +* re = realf( v ); +* // returns 5.0 +* +* im = imagf( v ); +* // returns 6.0 +*/ +function blockedmskfilter10d( x, mask, y ) { // eslint-disable-line max-statements, max-lines-per-function + var bsize; + var xbuf; + var mbuf; + var ybuf; + var xget; + var mget; + var yset; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dx6; + var dx7; + var dx8; + var dx9; + var dm0; + var dm1; + var dm2; + var dm3; + var dm4; + var dm5; + var dm6; + var dm7; + var dm8; + var dm9; + var dy0; + var ox1; + var ox2; + var ox3; + var ox4; + var ox5; + var ox6; + var ox7; + var ox8; + var ox9; + var om1; + var om2; + var om3; + var om4; + var om5; + var om6; + var om7; + var om8; + var om9; + var sh; + var s0; + var s1; + var s2; + var s3; + var s4; + var s5; + var s6; + var s7; + var s8; + var s9; + var sx; + var sm; + var ox; + var om; + var ix; + var im; + var iy; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + var i7; + var i8; + var i9; + var j0; + var j1; + var j2; + var j3; + var j4; + var j5; + var j6; + var j7; + var j8; + var j9; + var o; + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides, mask.strides ); + sh = o.sh; + sx = o.sx; + sm = o.sy; + + // Determine the block size: + bsize = blockSize( x.dtype, mask.dtype ); + + // Cache the indices of the first indexed elements in the respective ndarrays... + ox = x.offset; + om = mask.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + mbuf = mask.data; + ybuf = y.data; + + // Cache offset increments for the innermost loop... + dx0 = sx[0]; + dm0 = sm[0]; + dy0 = y.strides[0]; + + iy = y.offset; + + // Cache accessors: + xget = x.accessors[ 0 ]; + mget = mask.accessors[ 0 ]; + yset = y.accessors[ 1 ]; + + // Iterate over blocks... + for ( j9 = sh[9]; j9 > 0; ) { + if ( j9 < bsize ) { + s9 = j9; + j9 = 0; + } else { + s9 = bsize; + j9 -= bsize; + } + ox9 = ox + ( j9*sx[9] ); + om9 = om + ( j9*sm[9] ); + for ( j8 = sh[8]; j8 > 0; ) { + if ( j8 < bsize ) { + s8 = j8; + j8 = 0; + } else { + s8 = bsize; + j8 -= bsize; + } + dx9 = sx[9] - ( s8*sx[8] ); + dm9 = sm[9] - ( s8*sm[8] ); + ox8 = ox9 + ( j8*sx[8] ); + om8 = om9 + ( j8*sm[8] ); + for ( j7 = sh[7]; j7 > 0; ) { + if ( j7 < bsize ) { + s7 = j7; + j7 = 0; + } else { + s7 = bsize; + j7 -= bsize; + } + dx8 = sx[8] - ( s7*sx[7] ); + dm8 = sm[8] - ( s7*sm[7] ); + ox7 = ox8 + ( j7*sx[7] ); + om7 = om8 + ( j7*sm[7] ); + for ( j6 = sh[6]; j6 > 0; ) { + if ( j6 < bsize ) { + s6 = j6; + j6 = 0; + } else { + s6 = bsize; + j6 -= bsize; + } + dx7 = sx[7] - ( s6*sx[6] ); + dm7 = sm[7] - ( s6*sm[6] ); + ox6 = ox7 + ( j6*sx[6] ); + om6 = om7 + ( j6*sm[6] ); + for ( j5 = sh[5]; j5 > 0; ) { + if ( j5 < bsize ) { + s5 = j5; + j5 = 0; + } else { + s5 = bsize; + j5 -= bsize; + } + dx6 = sx[6] - ( s5*sx[5] ); + dm6 = sm[6] - ( s5*sm[5] ); + ox5 = ox6 + ( j5*sx[5] ); + om5 = om6 + ( j5*sm[5] ); + for ( j4 = sh[4]; j4 > 0; ) { + if ( j4 < bsize ) { + s4 = j4; + j4 = 0; + } else { + s4 = bsize; + j4 -= bsize; + } + dx5 = sx[5] - ( s4*sx[4] ); + dm5 = sm[5] - ( s4*sm[4] ); + ox4 = ox5 + ( j4*sx[4] ); + om4 = om5 + ( j4*sm[4] ); + for ( j3 = sh[3]; j3 > 0; ) { + if ( j3 < bsize ) { + s3 = j3; + j3 = 0; + } else { + s3 = bsize; + j3 -= bsize; + } + dx4 = sx[4] - ( s3*sx[3] ); + dm4 = sm[4] - ( s3*sm[3] ); + ox3 = ox4 + ( j3*sx[3] ); + om3 = om4 + ( j3*sm[3] ); + for ( j2 = sh[2]; j2 > 0; ) { + if ( j2 < bsize ) { + s2 = j2; + j2 = 0; + } else { + s2 = bsize; + j2 -= bsize; + } + dx3 = sx[3] - ( s2*sx[2] ); + dm3 = sm[3] - ( s2*sm[2] ); + ox2 = ox3 + ( j2*sx[2] ); + om2 = om3 + ( j2*sm[2] ); + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + dx2 = sx[2] - ( s1*sx[1] ); + dm2 = sm[2] - ( s1*sm[1] ); + ox1 = ox2 + ( j1*sx[1] ); + om1 = om2 + ( j1*sm[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute index offsets for the first input and output ndarray elements in the current block... + ix = ox1 + ( j0*sx[0] ); + im = om1 + ( j0*sm[0] ); + + // Compute loop offset increments... + dx1 = sx[1] - ( s0*sx[0] ); + dm1 = sm[1] - ( s0*sm[0] ); + + // Iterate over the ndarray dimensions... + for ( i9 = 0; i9 < s9; i9++ ) { + for ( i8 = 0; i8 < s8; i8++ ) { + for ( i7 = 0; i7 < s7; i7++ ) { + for ( i6 = 0; i6 < s6; i6++ ) { + for ( i5 = 0; i5 < s5; i5++ ) { + for ( i4 = 0; i4 < s4; i4++ ) { + for ( i3 = 0; i3 < s3; i3++ ) { + for ( i2 = 0; i2 < s2; i2++ ) { + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( mget( mbuf, im ) ) { + yset( ybuf, iy, xget( xbuf, ix ) ); + iy += dy0; + } + ix += dx0; + im += dm0; + } + ix += dx1; + im += dm1; + } + ix += dx2; + im += dm2; + } + ix += dx3; + im += dm3; + } + ix += dx4; + im += dm4; + } + ix += dx5; + im += dm5; + } + ix += dx6; + im += dm6; + } + ix += dx7; + im += dm7; + } + ix += dx8; + im += dm8; + } + ix += dx9; + im += dm9; + } + } + } + } + } + } + } + } + } + } + } +} + + +// EXPORTS // + +module.exports = blockedmskfilter10d; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js index d146fe7de5c..7e612cddc24 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js @@ -16,6 +16,8 @@ * limitations under the License. */ +/* eslint-disable max-len, id-length */ + 'use strict'; // MODULES // @@ -27,17 +29,45 @@ var format = require( '@stdlib/string/format' ); var numel = require( '@stdlib/ndarray/base/numel' ); var blockedaccessormskfilter2d = require( './2d_blocked_accessors.js' ); var blockedaccessormskfilter3d = require( './3d_blocked_accessors.js' ); +var blockedaccessormskfilter4d = require( './4d_blocked_accessors.js' ); +var blockedaccessormskfilter5d = require( './5d_blocked_accessors.js' ); +var blockedaccessormskfilter6d = require( './6d_blocked_accessors.js' ); +var blockedaccessormskfilter7d = require( './7d_blocked_accessors.js' ); +var blockedaccessormskfilter8d = require( './8d_blocked_accessors.js' ); +var blockedaccessormskfilter9d = require( './9d_blocked_accessors.js' ); +var blockedaccessormskfilter10d = require( './10d_blocked_accessors.js' ); var blockedmskfilter2d = require( './2d_blocked.js' ); var blockedmskfilter3d = require( './3d_blocked.js' ); +var blockedmskfilter4d = require( './4d_blocked.js' ); +var blockedmskfilter5d = require( './5d_blocked.js' ); +var blockedmskfilter6d = require( './6d_blocked.js' ); +var blockedmskfilter7d = require( './7d_blocked.js' ); +var blockedmskfilter8d = require( './8d_blocked.js' ); +var blockedmskfilter9d = require( './9d_blocked.js' ); +var blockedmskfilter10d = require( './10d_blocked.js' ); var accessormskfilter0d = require( './0d_accessors.js' ); var accessormskfilter1d = require( './1d_accessors.js' ); var accessormskfilter2d = require( './2d_accessors.js' ); var accessormskfilter3d = require( './3d_accessors.js' ); +var accessormskfilter4d = require( './4d_accessors.js' ); +var accessormskfilter5d = require( './5d_accessors.js' ); +var accessormskfilter6d = require( './6d_accessors.js' ); +var accessormskfilter7d = require( './7d_accessors.js' ); +var accessormskfilter8d = require( './8d_accessors.js' ); +var accessormskfilter9d = require( './9d_accessors.js' ); +var accessormskfilter10d = require( './10d_accessors.js' ); var accessormskfilternd = require( './nd_accessors.js' ); var mskfilter0d = require( './0d.js' ); var mskfilter1d = require( './1d.js' ); var mskfilter2d = require( './2d.js' ); var mskfilter3d = require( './3d.js' ); +var mskfilter4d = require( './4d.js' ); +var mskfilter5d = require( './5d.js' ); +var mskfilter6d = require( './6d.js' ); +var mskfilter7d = require( './7d.js' ); +var mskfilter8d = require( './8d.js' ); +var mskfilter9d = require( './9d.js' ); +var mskfilter10d = require( './10d.js' ); var mskfilternd = require( './nd.js' ); @@ -47,24 +77,52 @@ var MSKFILTER = [ mskfilter0d, mskfilter1d, mskfilter2d, - mskfilter3d + mskfilter3d, + mskfilter4d, + mskfilter5d, + mskfilter6d, + mskfilter7d, + mskfilter8d, + mskfilter9d, + mskfilter10d ]; var ACCESSOR_MSKFILTER = [ accessormskfilter0d, accessormskfilter1d, accessormskfilter2d, - accessormskfilter3d + accessormskfilter3d, + accessormskfilter4d, + accessormskfilter5d, + accessormskfilter6d, + accessormskfilter7d, + accessormskfilter8d, + accessormskfilter9d, + accessormskfilter10d ]; var BLOCKED_MSKFILTER = [ blockedmskfilter2d, - blockedmskfilter3d + blockedmskfilter3d, + blockedmskfilter4d, + blockedmskfilter5d, + blockedmskfilter6d, + blockedmskfilter7d, + blockedmskfilter8d, + blockedmskfilter9d, + blockedmskfilter10d ]; var BLOCKED_ACCESSOR_MSKFILTER = [ blockedaccessormskfilter2d, - blockedaccessormskfilter3d + blockedaccessormskfilter3d, + blockedaccessormskfilter4d, + blockedaccessormskfilter5d, + blockedaccessormskfilter6d, + blockedaccessormskfilter7d, + blockedaccessormskfilter8d, + blockedaccessormskfilter9d, + blockedaccessormskfilter10d ]; var MAX_DIMS = MSKFILTER.length - 1; From f1e0a811b8f2e13d6429d6776ff9beb4bec09fb4 Mon Sep 17 00:00:00 2001 From: Jaysukh-409 Date: Mon, 5 Aug 2024 20:36:01 +0530 Subject: [PATCH 18/34] docs: fix copy-paste error --- .../@stdlib/ndarray/base/mskfilter/lib/10d.js | 2 +- .../base/mskfilter/lib/10d_accessors.js | 2 +- .../ndarray/base/mskfilter/lib/10d_blocked.js | 4 +-- .../mskfilter/lib/10d_blocked_accessors.js | 4 +-- .../@stdlib/ndarray/base/mskfilter/lib/1d.js | 2 +- .../base/mskfilter/lib/1d_accessors.js | 2 +- .../@stdlib/ndarray/base/mskfilter/lib/2d.js | 2 +- .../base/mskfilter/lib/2d_accessors.js | 2 +- .../ndarray/base/mskfilter/lib/2d_blocked.js | 4 +-- .../mskfilter/lib/2d_blocked_accessors.js | 4 +-- .../@stdlib/ndarray/base/mskfilter/lib/3d.js | 2 +- .../base/mskfilter/lib/3d_accessors.js | 2 +- .../ndarray/base/mskfilter/lib/3d_blocked.js | 4 +-- .../mskfilter/lib/3d_blocked_accessors.js | 4 +-- .../@stdlib/ndarray/base/mskfilter/lib/4d.js | 2 +- .../base/mskfilter/lib/4d_accessors.js | 2 +- .../ndarray/base/mskfilter/lib/4d_blocked.js | 4 +-- .../mskfilter/lib/4d_blocked_accessors.js | 4 +-- .../@stdlib/ndarray/base/mskfilter/lib/5d.js | 2 +- .../base/mskfilter/lib/5d_accessors.js | 2 +- .../ndarray/base/mskfilter/lib/5d_blocked.js | 4 +-- .../mskfilter/lib/5d_blocked_accessors.js | 6 ++-- .../@stdlib/ndarray/base/mskfilter/lib/6d.js | 2 +- .../base/mskfilter/lib/6d_accessors.js | 2 +- .../ndarray/base/mskfilter/lib/6d_blocked.js | 4 +-- .../mskfilter/lib/6d_blocked_accessors.js | 6 ++-- .../@stdlib/ndarray/base/mskfilter/lib/7d.js | 2 +- .../base/mskfilter/lib/7d_accessors.js | 2 +- .../ndarray/base/mskfilter/lib/7d_blocked.js | 4 +-- .../mskfilter/lib/7d_blocked_accessors.js | 4 +-- .../@stdlib/ndarray/base/mskfilter/lib/8d.js | 2 +- .../base/mskfilter/lib/8d_accessors.js | 2 +- .../ndarray/base/mskfilter/lib/8d_blocked.js | 4 +-- .../mskfilter/lib/8d_blocked_accessors.js | 4 +-- .../@stdlib/ndarray/base/mskfilter/lib/9d.js | 2 +- .../base/mskfilter/lib/9d_accessors.js | 2 +- .../ndarray/base/mskfilter/lib/9d_blocked.js | 4 +-- .../mskfilter/lib/9d_blocked_accessors.js | 4 +-- .../ndarray/base/mskfilter/lib/index.js | 30 +++++++++---------- .../ndarray/base/mskfilter/lib/main.js | 1 - .../@stdlib/ndarray/base/mskfilter/lib/nd.js | 2 +- .../base/mskfilter/lib/nd_accessors.js | 2 +- 42 files changed, 74 insertions(+), 77 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d.js index 2318dd0381a..59f5deef3d9 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d.js @@ -207,7 +207,7 @@ function mskfilter10d( x, mask, y ) { // eslint-disable-line max-statements im = mask.offset; iy = y.offset; - // Cache references to the input and output ndarray buffers... + // Cache references to the input, mask and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_accessors.js index dea496f94a3..8fa7132b3c5 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_accessors.js @@ -240,7 +240,7 @@ function mskfilter10d( x, mask, y ) { // eslint-disable-line max-statements im = mask.offset; iy = y.offset; - // Cache references to the input and output ndarray buffers... + // Cache references to the input, mask and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_blocked.js index 0c6543290e1..b312643e24c 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_blocked.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_blocked.js @@ -182,7 +182,7 @@ function blockedmskfilter10d( x, mask, y ) { // eslint-disable-line max-statemen ox = x.offset; om = mask.offset; - // Cache references to the input and output ndarray buffers... + // Cache references to the input, mask and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; @@ -309,7 +309,7 @@ function blockedmskfilter10d( x, mask, y ) { // eslint-disable-line max-statemen s0 = bsize; j0 -= bsize; } - // Compute index offsets for the first input and output ndarray elements in the current block... + // Compute index offsets for the first input and mask ndarray elements in the current block... ix = ox1 + ( j0*sx[0] ); im = om1 + ( j0*sm[0] ); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_blocked_accessors.js index b0e2c3c9c05..59df981cf13 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_blocked_accessors.js @@ -215,7 +215,7 @@ function blockedmskfilter10d( x, mask, y ) { // eslint-disable-line max-statemen ox = x.offset; om = mask.offset; - // Cache references to the input and output ndarray buffers... + // Cache references to the input, mask and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; @@ -347,7 +347,7 @@ function blockedmskfilter10d( x, mask, y ) { // eslint-disable-line max-statemen s0 = bsize; j0 -= bsize; } - // Compute index offsets for the first input and output ndarray elements in the current block... + // Compute index offsets for the first input and mask ndarray elements in the current block... ix = ox1 + ( j0*sx[0] ); im = om1 + ( j0*sm[0] ); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d.js index 123a29869ab..a3c3720cccc 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d.js @@ -101,7 +101,7 @@ function mskfilter1d( x, mask, y ) { im = mask.offset; iy = y.offset; - // Cache references to the input and output ndarray buffers... + // Cache references to the input, mask and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d_accessors.js index 3f12e0976ab..1b8aab60017 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d_accessors.js @@ -125,7 +125,7 @@ function mskfilter1d( x, mask, y ) { im = mask.offset; iy = y.offset; - // Cache references to the input and output ndarray buffers... + // Cache references to the input, mask and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d.js index 80687ae9aeb..a6d7c705446 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d.js @@ -125,7 +125,7 @@ function mskfilter2d( x, mask, y ) { im = mask.offset; iy = y.offset; - // Cache references to the input and output ndarray buffers... + // Cache references to the input, mask and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_accessors.js index 74422f7a3c4..f338e7633f0 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_accessors.js @@ -149,7 +149,7 @@ function mskfilter2d( x, mask, y ) { im = mask.offset; iy = y.offset; - // Cache references to the input and output ndarray buffers... + // Cache references to the input, mask and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked.js index 11166656970..5a5a7a86736 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked.js @@ -124,7 +124,7 @@ function blockedmskfilter2d( x, mask, y ) { ox = x.offset; om = mask.offset; - // Cache references to the input and output ndarray buffers... + // Cache references to the input, mask and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; @@ -155,7 +155,7 @@ function blockedmskfilter2d( x, mask, y ) { s0 = bsize; j0 -= bsize; } - // Compute index offsets for the first input and output ndarray elements in the current block... + // Compute index offsets for the first input and mask ndarray elements in the current block... ix = ox1 + ( j0*sx[0] ); im = om1 + ( j0*sm[0] ); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked_accessors.js index 97a98538463..01f1e87896e 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked_accessors.js @@ -148,7 +148,7 @@ function blockedmskfilter2d( x, mask, y ) { ox = x.offset; om = mask.offset; - // Cache references to the input and output ndarray buffers... + // Cache references to the input, mask and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; @@ -184,7 +184,7 @@ function blockedmskfilter2d( x, mask, y ) { s0 = bsize; j0 -= bsize; } - // Compute index offsets for the first input and output ndarray elements in the current block... + // Compute index offsets for the first input and mask ndarray elements in the current block... ix = ox1 + ( j0*sx[0] ); im = om1 + ( j0*sm[0] ); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d.js index 6510121bcb7..6117aba488a 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d.js @@ -135,7 +135,7 @@ function mskfilter3d( x, mask, y ) { im = mask.offset; iy = y.offset; - // Cache references to the input and output ndarray buffers... + // Cache references to the input, mask and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_accessors.js index 970d06848bc..a168ddc1f98 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_accessors.js @@ -168,7 +168,7 @@ function mskfilter3d( x, mask, y ) { im = mask.offset; iy = y.offset; - // Cache references to the input and output ndarray buffers... + // Cache references to the input, mask and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_blocked.js index d5e3a2c368a..346868cd8cf 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_blocked.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_blocked.js @@ -133,7 +133,7 @@ function blockedmskfilter3d( x, mask, y ) { ox = x.offset; om = mask.offset; - // Cache references to the input and output ndarray buffers... + // Cache references to the input, mask and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; @@ -176,7 +176,7 @@ function blockedmskfilter3d( x, mask, y ) { s0 = bsize; j0 -= bsize; } - // Compute index offsets for the first input and output ndarray elements in the current block... + // Compute index offsets for the first input and mask ndarray elements in the current block... ix = ox1 + ( j0*sx[0] ); im = om1 + ( j0*sm[0] ); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_blocked_accessors.js index 46906777637..94038d45bc9 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_blocked_accessors.js @@ -166,7 +166,7 @@ function blockedmskfilter3d( x, mask, y ) { ox = x.offset; om = mask.offset; - // Cache references to the input and output ndarray buffers... + // Cache references to the input, mask and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; @@ -214,7 +214,7 @@ function blockedmskfilter3d( x, mask, y ) { s0 = bsize; j0 -= bsize; } - // Compute index offsets for the first input and output ndarray elements in the current block... + // Compute index offsets for the first input and mask ndarray elements in the current block... ix = ox1 + ( j0*sx[0] ); im = om1 + ( j0*sm[0] ); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d.js index 6804d1af897..d269def4db8 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d.js @@ -145,7 +145,7 @@ function mskfilter4d( x, mask, y ) { im = mask.offset; iy = y.offset; - // Cache references to the input and output ndarray buffers... + // Cache references to the input, mask and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_accessors.js index 8bd147352df..7b82ebe9854 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_accessors.js @@ -178,7 +178,7 @@ function mskfilter4d( x, mask, y ) { im = mask.offset; iy = y.offset; - // Cache references to the input and output ndarray buffers... + // Cache references to the input, mask and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_blocked.js index c7414945d2b..22dd7b5f6f7 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_blocked.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_blocked.js @@ -140,7 +140,7 @@ function blockedmskfilter4d( x, mask, y ) { // eslint-disable-line max-statement ox = x.offset; om = mask.offset; - // Cache references to the input and output ndarray buffers... + // Cache references to the input, mask and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; @@ -195,7 +195,7 @@ function blockedmskfilter4d( x, mask, y ) { // eslint-disable-line max-statement s0 = bsize; j0 -= bsize; } - // Compute index offsets for the first input and output ndarray elements in the current block... + // Compute index offsets for the first input and mask ndarray elements in the current block... ix = ox1 + ( j0*sx[0] ); im = om1 + ( j0*sm[0] ); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_blocked_accessors.js index af78bf7c093..b8151eddcea 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_blocked_accessors.js @@ -173,7 +173,7 @@ function blockedmskfilter4d( x, mask, y ) { // eslint-disable-line max-statement ox = x.offset; om = mask.offset; - // Cache references to the input and output ndarray buffers... + // Cache references to the input, mask and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; @@ -233,7 +233,7 @@ function blockedmskfilter4d( x, mask, y ) { // eslint-disable-line max-statement s0 = bsize; j0 -= bsize; } - // Compute index offsets for the first input and output ndarray elements in the current block... + // Compute index offsets for the first input and mask ndarray elements in the current block... ix = ox1 + ( j0*sx[0] ); im = om1 + ( j0*sm[0] ); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d.js index b62ba398d3e..b1e0467108a 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d.js @@ -157,7 +157,7 @@ function mskfilter5d( x, mask, y ) { im = mask.offset; iy = y.offset; - // Cache references to the input and output ndarray buffers... + // Cache references to the input, mask and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_accessors.js index b08c27fec9f..4307266f4a8 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_accessors.js @@ -190,7 +190,7 @@ function mskfilter5d( x, mask, y ) { im = mask.offset; iy = y.offset; - // Cache references to the input and output ndarray buffers... + // Cache references to the input, mask and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_blocked.js index fe9c99e4edb..96f9ab1db80 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_blocked.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_blocked.js @@ -147,7 +147,7 @@ function blockedmskfilter5d( x, mask, y ) { // eslint-disable-line max-statement ox = x.offset; om = mask.offset; - // Cache references to the input and output ndarray buffers... + // Cache references to the input, mask and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; @@ -214,7 +214,7 @@ function blockedmskfilter5d( x, mask, y ) { // eslint-disable-line max-statement s0 = bsize; j0 -= bsize; } - // Compute index offsets for the first input and output ndarray elements in the current block... + // Compute index offsets for the first input and mask ndarray elements in the current block... ix = ox1 + ( j0*sx[0] ); im = om1 + ( j0*sm[0] ); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_blocked_accessors.js index bd7d0b35183..7756887ee69 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_blocked_accessors.js @@ -16,7 +16,7 @@ * limitations under the License. */ -/* eslint-disable max-depth */ +/* eslint-disable max-depth, max-len */ 'use strict'; @@ -180,7 +180,7 @@ function blockedmskfilter5d( x, mask, y ) { // eslint-disable-line max-statement ox = x.offset; om = mask.offset; - // Cache references to the input and output ndarray buffers... + // Cache references to the input, mask and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; @@ -252,7 +252,7 @@ function blockedmskfilter5d( x, mask, y ) { // eslint-disable-line max-statement s0 = bsize; j0 -= bsize; } - // Compute index offsets for the first input and output ndarray elements in the current block... + // Compute index offsets for the first input and mask ndarray elements in the current block... ix = ox1 + ( j0*sx[0] ); im = om1 + ( j0*sm[0] ); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d.js index d2f316857fe..71033c9bf8d 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d.js @@ -167,7 +167,7 @@ function mskfilter6d( x, mask, y ) { // eslint-disable-line max-statements im = mask.offset; iy = y.offset; - // Cache references to the input and output ndarray buffers... + // Cache references to the input, mask and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_accessors.js index e515820726f..f199457a9d1 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_accessors.js @@ -200,7 +200,7 @@ function mskfilter6d( x, mask, y ) { // eslint-disable-line max-statements im = mask.offset; iy = y.offset; - // Cache references to the input and output ndarray buffers... + // Cache references to the input, mask and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_blocked.js index fe06f9d8cfe..4eb7d1c7b25 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_blocked.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_blocked.js @@ -154,7 +154,7 @@ function blockedmskfilter6d( x, mask, y ) { // eslint-disable-line max-statement ox = x.offset; om = mask.offset; - // Cache references to the input and output ndarray buffers... + // Cache references to the input, mask and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; @@ -233,7 +233,7 @@ function blockedmskfilter6d( x, mask, y ) { // eslint-disable-line max-statement s0 = bsize; j0 -= bsize; } - // Compute index offsets for the first input and output ndarray elements in the current block... + // Compute index offsets for the first input and mask ndarray elements in the current block... ix = ox1 + ( j0*sx[0] ); im = om1 + ( j0*sm[0] ); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_blocked_accessors.js index bdd1a772c4d..4179af76d28 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_blocked_accessors.js @@ -16,7 +16,7 @@ * limitations under the License. */ -/* eslint-disable max-depth */ +/* eslint-disable max-depth, max-len */ 'use strict'; @@ -187,7 +187,7 @@ function blockedmskfilter6d( x, mask, y ) { // eslint-disable-line max-statement ox = x.offset; om = mask.offset; - // Cache references to the input and output ndarray buffers... + // Cache references to the input, mask and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; @@ -271,7 +271,7 @@ function blockedmskfilter6d( x, mask, y ) { // eslint-disable-line max-statement s0 = bsize; j0 -= bsize; } - // Compute index offsets for the first input and output ndarray elements in the current block... + // Compute index offsets for the first input and mask ndarray elements in the current block... ix = ox1 + ( j0*sx[0] ); im = om1 + ( j0*sm[0] ); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d.js index d592a1649a0..c8e45d29582 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d.js @@ -177,7 +177,7 @@ function mskfilter7d( x, mask, y ) { // eslint-disable-line max-statements im = mask.offset; iy = y.offset; - // Cache references to the input and output ndarray buffers... + // Cache references to the input, mask and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_accessors.js index 94830811afe..6d9dda1e2a9 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_accessors.js @@ -210,7 +210,7 @@ function mskfilter7d( x, mask, y ) { // eslint-disable-line max-statements im = mask.offset; iy = y.offset; - // Cache references to the input and output ndarray buffers... + // Cache references to the input, mask and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_blocked.js index 0f938a6d1c3..2cc89d61350 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_blocked.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_blocked.js @@ -161,7 +161,7 @@ function blockedmskfilter7d( x, mask, y ) { // eslint-disable-line max-statement ox = x.offset; om = mask.offset; - // Cache references to the input and output ndarray buffers... + // Cache references to the input, mask and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; @@ -252,7 +252,7 @@ function blockedmskfilter7d( x, mask, y ) { // eslint-disable-line max-statement s0 = bsize; j0 -= bsize; } - // Compute index offsets for the first input and output ndarray elements in the current block... + // Compute index offsets for the first input and mask ndarray elements in the current block... ix = ox1 + ( j0*sx[0] ); im = om1 + ( j0*sm[0] ); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_blocked_accessors.js index 9fd7fcc115e..05941d7e5c6 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_blocked_accessors.js @@ -194,7 +194,7 @@ function blockedmskfilter7d( x, mask, y ) { // eslint-disable-line max-statement ox = x.offset; om = mask.offset; - // Cache references to the input and output ndarray buffers... + // Cache references to the input, mask and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; @@ -290,7 +290,7 @@ function blockedmskfilter7d( x, mask, y ) { // eslint-disable-line max-statement s0 = bsize; j0 -= bsize; } - // Compute index offsets for the first input and output ndarray elements in the current block... + // Compute index offsets for the first input and mask ndarray elements in the current block... ix = ox1 + ( j0*sx[0] ); im = om1 + ( j0*sm[0] ); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d.js index 10b5b4b6969..9ceb2462658 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d.js @@ -187,7 +187,7 @@ function mskfilter8d( x, mask, y ) { // eslint-disable-line max-statements im = mask.offset; iy = y.offset; - // Cache references to the input and output ndarray buffers... + // Cache references to the input, mask and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_accessors.js index 17ee8fd8ae9..c5b0350c58a 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_accessors.js @@ -220,7 +220,7 @@ function mskfilter8d( x, mask, y ) { // eslint-disable-line max-statements im = mask.offset; iy = y.offset; - // Cache references to the input and output ndarray buffers... + // Cache references to the input, mask and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_blocked.js index e2e25532bb3..7b83585b053 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_blocked.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_blocked.js @@ -168,7 +168,7 @@ function blockedmskfilter8d( x, mask, y ) { // eslint-disable-line max-statement ox = x.offset; om = mask.offset; - // Cache references to the input and output ndarray buffers... + // Cache references to the input, mask and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; @@ -271,7 +271,7 @@ function blockedmskfilter8d( x, mask, y ) { // eslint-disable-line max-statement s0 = bsize; j0 -= bsize; } - // Compute index offsets for the first input and output ndarray elements in the current block... + // Compute index offsets for the first input and mask ndarray elements in the current block... ix = ox1 + ( j0*sx[0] ); im = om1 + ( j0*sm[0] ); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_blocked_accessors.js index 728f2a5d421..815f4999d82 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_blocked_accessors.js @@ -201,7 +201,7 @@ function blockedmskfilter8d( x, mask, y ) { // eslint-disable-line max-statement ox = x.offset; om = mask.offset; - // Cache references to the input and output ndarray buffers... + // Cache references to the input, mask and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; @@ -309,7 +309,7 @@ function blockedmskfilter8d( x, mask, y ) { // eslint-disable-line max-statement s0 = bsize; j0 -= bsize; } - // Compute index offsets for the first input and output ndarray elements in the current block... + // Compute index offsets for the first input and mask ndarray elements in the current block... ix = ox1 + ( j0*sx[0] ); im = om1 + ( j0*sm[0] ); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d.js index 83d1983aad3..509580e2aff 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d.js @@ -197,7 +197,7 @@ function mskfilter9d( x, mask, y ) { // eslint-disable-line max-statements im = mask.offset; iy = y.offset; - // Cache references to the input and output ndarray buffers... + // Cache references to the input, mask and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_accessors.js index 9ea86292a7b..9b8cc59c1a3 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_accessors.js @@ -230,7 +230,7 @@ function mskfilter9d( x, mask, y ) { // eslint-disable-line max-statements im = mask.offset; iy = y.offset; - // Cache references to the input and output ndarray buffers... + // Cache references to the input, mask and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_blocked.js index 3bb1f2d4e09..7712036cef2 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_blocked.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_blocked.js @@ -175,7 +175,7 @@ function blockedmskfilter9d( x, mask, y ) { // eslint-disable-line max-statement ox = x.offset; om = mask.offset; - // Cache references to the input and output ndarray buffers... + // Cache references to the input, mask and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; @@ -290,7 +290,7 @@ function blockedmskfilter9d( x, mask, y ) { // eslint-disable-line max-statement s0 = bsize; j0 -= bsize; } - // Compute index offsets for the first input and output ndarray elements in the current block... + // Compute index offsets for the first input and mask ndarray elements in the current block... ix = ox1 + ( j0*sx[0] ); im = om1 + ( j0*sm[0] ); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_blocked_accessors.js index 05031eb36da..c6bef507bb9 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_blocked_accessors.js @@ -208,7 +208,7 @@ function blockedmskfilter9d( x, mask, y ) { // eslint-disable-line max-statement ox = x.offset; om = mask.offset; - // Cache references to the input and output ndarray buffers... + // Cache references to the input, mask and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; @@ -328,7 +328,7 @@ function blockedmskfilter9d( x, mask, y ) { // eslint-disable-line max-statement s0 = bsize; j0 -= bsize; } - // Compute index offsets for the first input and output ndarray elements in the current block... + // Compute index offsets for the first input and mask ndarray elements in the current block... ix = ox1 + ( j0*sx[0] ); im = om1 + ( j0*sm[0] ); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/index.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/index.js index 21a98b3c2b2..1848a8768a7 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/index.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/index.js @@ -19,59 +19,57 @@ 'use strict'; /** -* Apply a mask to a provided input ndarray and assigns to one-dimensional output ndarray. +* Apply a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. * * @module @stdlib/ndarray/base/mskfilter * * @example * var Float64Array = require( '@stdlib/array/float64' ); +* var Uint8Array = require( '@stdlib/array/uint8' ); * var mskfilter = require( '@stdlib/ndarray/base/mskfilter' ); * -* // 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 mbuf = new Float64Array( [ 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 ] ); -* * // Define the shape of the input and mask arrays: * var shape = [ 3, 1, 2 ]; * * // Define the array strides: * var sx = [ 4, 4, 1 ]; +* var sm = [ 2, 2, 1 ]; +* var sy = [ 1 ]; * * // Define the index offsets: -* var ox = 0; +* var ox = 1; * var om = 0; * * // Create the input, mask and output ndarray-like objects: * var x = { * 'dtype': 'float64', -* 'data': xbuf, +* 'data': 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 ] ), * 'shape': shape, * 'strides': sx, * 'offset': ox, * 'order': 'row-major' * }; * var mask = { -* 'dtype': 'float64', -* 'data': mbuf, +* 'dtype': 'uint8', +* 'data': new Uint8Array( [ 1, 0, 1, 0, 1, 0 ] ), * 'shape': shape, -* 'strides': sy, +* 'strides': sm, * 'offset': om, * 'order': 'row-major' * }; * var out = { * 'dtype': 'float64', -* 'data': new Float64Array( 4 ), -* 'shape': [ 4 ], -* 'strides': [ 1 ], +* 'data': new Float64Array( 3 ), +* 'shape': [ 3 ], +* 'strides': sy, * 'offset': 0, * 'order': 'row-major' * }; * -* // Copy elements: * mskfilter( [ x, mask, out ] ); * * console.log( out.data ); -* // => [ 1.0, 5.0, 9.0, 11.0 ] +* // => [ 2.0, 6.0, 10.0 ] */ // MODULES // @@ -81,4 +79,4 @@ var main = require( './main.js' ); // EXPORTS // -module.exports = main; \ No newline at end of file +module.exports = main; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js index 7e612cddc24..9de91eca315 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js @@ -192,7 +192,6 @@ var MAX_DIMS = MSKFILTER.length - 1; * 'order': 'row-major' * }; * -* // Copy elements: * mskfilter( [ x, mask, out ] ); * * console.log( out.data ); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/nd.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/nd.js index da0c6a49ffe..ab9f6005b2f 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/nd.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/nd.js @@ -112,7 +112,7 @@ function mskfilternd( x, mask, y ) { // Compute the total number of elements over which to iterate: len = numel( sh ); - // Cache references to the input and output ndarray data buffers: + // Cache references to the input, mask and output ndarray data buffers: xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/nd_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/nd_accessors.js index 785dacb5853..9f98e02a7db 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/nd_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/nd_accessors.js @@ -145,7 +145,7 @@ function mskfilternd( x, mask, y ) { // Compute the total number of elements over which to iterate: len = numel( sh ); - // Cache references to the input and output ndarray data buffers: + // Cache references to the input, mask and output ndarray data buffers: xbuf = x.data; mbuf = mask.data; ybuf = y.data; From 467a34f9c1e1cd0487ee03ce600d4ec909f227e2 Mon Sep 17 00:00:00 2001 From: Jaysukh-409 Date: Thu, 8 Aug 2024 14:22:59 +0530 Subject: [PATCH 19/34] refactor: apply suggestions --- .../@stdlib/ndarray/base/mskfilter/README.md | 10 +- .../@stdlib/ndarray/base/mskfilter/lib/0d.js | 10 +- .../base/mskfilter/lib/0d_accessors.js | 14 +- .../@stdlib/ndarray/base/mskfilter/lib/10d.js | 4 +- .../base/mskfilter/lib/10d_accessors.js | 8 +- .../ndarray/base/mskfilter/lib/10d_blocked.js | 4 +- .../mskfilter/lib/10d_blocked_accessors.js | 8 +- .../@stdlib/ndarray/base/mskfilter/lib/1d.js | 4 +- .../base/mskfilter/lib/1d_accessors.js | 4 +- .../@stdlib/ndarray/base/mskfilter/lib/2d.js | 4 +- .../base/mskfilter/lib/2d_accessors.js | 4 +- .../ndarray/base/mskfilter/lib/2d_blocked.js | 4 +- .../mskfilter/lib/2d_blocked_accessors.js | 4 +- .../@stdlib/ndarray/base/mskfilter/lib/3d.js | 4 +- .../base/mskfilter/lib/3d_accessors.js | 8 +- .../ndarray/base/mskfilter/lib/3d_blocked.js | 4 +- .../mskfilter/lib/3d_blocked_accessors.js | 8 +- .../@stdlib/ndarray/base/mskfilter/lib/4d.js | 4 +- .../base/mskfilter/lib/4d_accessors.js | 8 +- .../ndarray/base/mskfilter/lib/4d_blocked.js | 4 +- .../mskfilter/lib/4d_blocked_accessors.js | 8 +- .../@stdlib/ndarray/base/mskfilter/lib/5d.js | 4 +- .../base/mskfilter/lib/5d_accessors.js | 8 +- .../ndarray/base/mskfilter/lib/5d_blocked.js | 4 +- .../mskfilter/lib/5d_blocked_accessors.js | 8 +- .../@stdlib/ndarray/base/mskfilter/lib/6d.js | 4 +- .../base/mskfilter/lib/6d_accessors.js | 8 +- .../ndarray/base/mskfilter/lib/6d_blocked.js | 4 +- .../mskfilter/lib/6d_blocked_accessors.js | 8 +- .../@stdlib/ndarray/base/mskfilter/lib/7d.js | 4 +- .../base/mskfilter/lib/7d_accessors.js | 8 +- .../ndarray/base/mskfilter/lib/7d_blocked.js | 4 +- .../mskfilter/lib/7d_blocked_accessors.js | 8 +- .../@stdlib/ndarray/base/mskfilter/lib/8d.js | 4 +- .../base/mskfilter/lib/8d_accessors.js | 8 +- .../ndarray/base/mskfilter/lib/8d_blocked.js | 4 +- .../mskfilter/lib/8d_blocked_accessors.js | 8 +- .../@stdlib/ndarray/base/mskfilter/lib/9d.js | 4 +- .../base/mskfilter/lib/9d_accessors.js | 8 +- .../ndarray/base/mskfilter/lib/9d_blocked.js | 4 +- .../mskfilter/lib/9d_blocked_accessors.js | 8 +- .../ndarray/base/mskfilter/lib/index.js | 4 +- .../ndarray/base/mskfilter/lib/main.js | 4 +- .../@stdlib/ndarray/base/mskfilter/lib/nd.js | 4 +- .../base/mskfilter/lib/nd_accessors.js | 4 +- .../ndarray/base/mskfilter/package.json | 120 +++++++++--------- 46 files changed, 198 insertions(+), 188 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/README.md b/lib/node_modules/@stdlib/ndarray/base/mskfilter/README.md index d349ac1bcbe..ad5aa1c4cdb 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/README.md +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/README.md @@ -75,4 +75,12 @@ Each provided ndarray should be an object with the following properties:
- \ No newline at end of file + + + + + + + diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/0d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/0d.js index 15ed6c91389..67d3b93d54c 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/0d.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/0d.js @@ -47,7 +47,7 @@ * * var x = { * 'dtype': 'float64', -* 'data': new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ), +* 'data': new Float64Array( [ 1.0 ] ), * 'shape': shape, * 'strides': sx, * 'offset': ox, @@ -56,7 +56,7 @@ * * var mask = { * 'dtype': 'uint8', -* 'data': new Uint8Array( [ 1, 0, 1, 0, 1 ] ), +* 'data': new Uint8Array( [ 1 ] ), * 'shape': shape, * 'strides': sm, * 'offset': om, @@ -65,8 +65,8 @@ * * var y = { * 'dtype': 'float64', -* 'data': new Float64Array( 3 ), -* 'shape': [ 3 ], +* 'data': new Float64Array( 1 ), +* 'shape': [ 1 ], * 'strides': sy, * 'offset': 0, * 'order': 'row-major' @@ -75,7 +75,7 @@ * mskfilter0d( x, mask, y ); * * console.log( y.data ); -* // => [ 1.0, 0.0, 0.0 ] +* // => [ 1.0 ] */ function mskfilter0d( x, mask, y ) { if ( mask.data[ mask.offset ] ) { diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/0d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/0d_accessors.js index 0c068e55346..20feda65f64 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/0d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/0d_accessors.js @@ -16,6 +16,8 @@ * limitations under the License. */ +/* eslint-disable max-len */ + 'use strict'; // MAIN // @@ -33,8 +35,8 @@ * var BooleanArray = require( '@stdlib/array/bool' ); * var Complex64Array = require( '@stdlib/array/complex64' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); -* var realf = require( '@stdlib/complex/realf' ); -* var imagf = require( '@stdlib/complex/imagf' ); +* var realf = require( '@stdlib/complex/float32/real' ); +* var imagf = require( '@stdlib/complex/float32/imag' ); * * // Define the shape of the array: * var shape = []; @@ -59,7 +61,7 @@ * * var x = { * 'dtype': 'complex64', -* 'data': new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ), +* 'data': new Complex64Array( [ 1.0, 2.0 ] ), * 'shape': shape, * 'strides': sx, * 'offset': ox, @@ -69,7 +71,7 @@ * * var mask = { * 'dtype': 'bool', -* 'data': new BooleanArray( [ 1, 0, 1, 0 ] ), +* 'data': new BooleanArray( [ 1 ] ), * 'shape': shape, * 'strides': sm, * 'offset': om, @@ -79,8 +81,8 @@ * * var y = { * 'dtype': 'complex64', -* 'data': new Complex64Array( 2 ), -* 'shape': [ 2 ], +* 'data': new Complex64Array( 1 ), +* 'shape': [ 1 ], * 'strides': sy, * 'offset': 0, * 'order': 'row-major', diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d.js index 59f5deef3d9..d89340f85b7 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d.js @@ -39,7 +39,7 @@ * var shape = [ 1, 1, 1, 1, 1, 1, 1, 3, 1, 2 ]; * * // Define the array strides: -* var sx = [ 12, 12, 12, 12, 12, 12, 12, 4, 4, 1 ]; +* var sx = [ 6, 6, 6, 6, 6, 6, 6, 2, 2, 1 ]; * var sm = [ 6, 6, 6, 6, 6, 6, 6, 2, 2, 1 ]; * var sy = [ 1 ]; * @@ -77,7 +77,7 @@ * mskfilter10d( x, mask, y ); * * console.log( y.data ); -* // => [ 2.0, 6.0, 10.0 ] +* // => [ 2.0, 4.0, 6.0 ] */ function mskfilter10d( x, mask, y ) { // eslint-disable-line max-statements var xbuf; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_accessors.js index 8fa7132b3c5..529326a570a 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_accessors.js @@ -35,15 +35,15 @@ * var BooleanArray = require( '@stdlib/array/bool' ); * var Complex64Array = require( '@stdlib/array/complex64' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); -* var realf = require( '@stdlib/complex/realf' ); -* var imagf = require( '@stdlib/complex/imagf' ); +* var realf = require( '@stdlib/complex/float32/real' ); +* var imagf = require( '@stdlib/complex/float32/imag' ); * * // Define the shape of the array: * var shape = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 ]; * * // Define the array strides: -* var sx = [ 2, 2, 2, 2, 2, 2, 2, 2, 2, 1 ]; -* var sm = [ 2, 2, 2, 2, 2, 2, 2, 2, 2, 1 ]; +* var sx = [ 4, 4, 4, 4, 4, 4, 4, 4, 2, 1 ]; +* var sm = [ 4, 4, 4, 4, 4, 4, 4, 4, 2, 1 ]; * var sy = [ 1 ]; * * // Define the index offset: diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_blocked.js index b312643e24c..44d6d50055f 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_blocked.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_blocked.js @@ -45,7 +45,7 @@ var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); * var shape = [ 1, 1, 1, 1, 1, 1, 1, 3, 1, 2 ]; * * // Define the array strides: -* var sx = [ 12, 12, 12, 12, 12, 12, 12, 4, 4, 1 ]; +* var sx = [ 6, 6, 6, 6, 6, 6, 6, 2, 2, 1 ]; * var sm = [ 6, 6, 6, 6, 6, 6, 6, 2, 2, 1 ]; * var sy = [ 1 ]; * @@ -83,7 +83,7 @@ var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); * blockedmskfilter10d( x, mask, y ); * * console.log( y.data ); -* // => [ 2.0, 6.0, 10.0 ] +* // => [ 2.0, 4.0, 6.0 ] */ function blockedmskfilter10d( x, mask, y ) { // eslint-disable-line max-statements, max-lines-per-function var bsize; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_blocked_accessors.js index 59df981cf13..1d4727e5064 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_blocked_accessors.js @@ -41,15 +41,15 @@ var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); * var BooleanArray = require( '@stdlib/array/bool' ); * var Complex64Array = require( '@stdlib/array/complex64' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); -* var realf = require( '@stdlib/complex/realf' ); -* var imagf = require( '@stdlib/complex/imagf' ); +* var realf = require( '@stdlib/complex/float32/real' ); +* var imagf = require( '@stdlib/complex/float32/imag' ); * * // Define the shape of the array: * var shape = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 ]; * * // Define the array strides: -* var sx = [ 2, 2, 2, 2, 2, 2, 2, 2, 2, 1 ]; -* var sm = [ 2, 2, 2, 2, 2, 2, 2, 2, 2, 1 ]; +* var sx = [ 4, 4, 4, 4, 4, 4, 4, 4, 2, 1 ]; +* var sm = [ 4, 4, 4, 4, 4, 4, 4, 4, 2, 1 ]; * var sy = [ 1 ]; * * // Define the index offset: diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d.js index a3c3720cccc..3e9fe59e25a 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d.js @@ -37,7 +37,7 @@ * var shape = [ 5 ]; * * // Define the array strides: -* var sx = [ 2 ]; +* var sx = [ 1 ]; * var sm = [ 1 ]; * var sy = [ 1 ]; * @@ -75,7 +75,7 @@ * mskfilter1d( x, mask, y ); * * console.log( y.data ); -* // => [ 2.0, 6.0, 10.0 ] +* // => [ 2.0, 4.0, 6.0 ] */ function mskfilter1d( x, mask, y ) { var xbuf; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d_accessors.js index 1b8aab60017..93aab3237d9 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d_accessors.js @@ -33,8 +33,8 @@ * var BooleanArray = require( '@stdlib/array/bool' ); * var Complex64Array = require( '@stdlib/array/complex64' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); -* var realf = require( '@stdlib/complex/realf' ); -* var imagf = require( '@stdlib/complex/imagf' ); +* var realf = require( '@stdlib/complex/float32/real' ); +* var imagf = require( '@stdlib/complex/float32/imag' ); * * // Define the shape of the array: * var shape = [ 3 ]; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d.js index a6d7c705446..7097bd74568 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d.js @@ -37,7 +37,7 @@ * var shape = [ 2, 2 ]; * * // Define the array strides: -* var sx = [ 4, 1 ]; +* var sx = [ 2, 1 ]; * var sm = [ 2, 1 ]; * var sy = [ 1 ]; * @@ -75,7 +75,7 @@ * mskfilter2d( x, mask, y ); * * console.log( y.data ); -* // => [ 1.0, 5.0 ] +* // => [ 1.0, 3.0 ] */ function mskfilter2d( x, mask, y ) { var xbuf; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_accessors.js index f338e7633f0..1c989385654 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_accessors.js @@ -33,8 +33,8 @@ * var BooleanArray = require( '@stdlib/array/bool' ); * var Complex64Array = require( '@stdlib/array/complex64' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); -* var realf = require( '@stdlib/complex/realf' ); -* var imagf = require( '@stdlib/complex/imagf' ); +* var realf = require( '@stdlib/complex/float32/real' ); +* var imagf = require( '@stdlib/complex/float32/imag' ); * * // Define the shape of the array: * var shape = [ 2, 2 ]; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked.js index 5a5a7a86736..72812cb61e1 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked.js @@ -43,7 +43,7 @@ var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); * var shape = [ 2, 2 ]; * * // Define the array strides: -* var sx = [ 4, 1 ]; +* var sx = [ 2, 1 ]; * var sm = [ 2, 1 ]; * var sy = [ 1 ]; * @@ -81,7 +81,7 @@ var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); * blockedmskfilter2d( x, mask, y ); * * console.log( y.data ); -* // => [ 1.0, 5.0 ] +* // => [ 1.0, 3.0 ] */ function blockedmskfilter2d( x, mask, y ) { var bsize; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked_accessors.js index 01f1e87896e..c2a6136404f 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked_accessors.js @@ -39,8 +39,8 @@ var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); * var BooleanArray = require( '@stdlib/array/bool' ); * var Complex64Array = require( '@stdlib/array/complex64' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); -* var realf = require( '@stdlib/complex/realf' ); -* var imagf = require( '@stdlib/complex/imagf' ); +* var realf = require( '@stdlib/complex/float32/real' ); +* var imagf = require( '@stdlib/complex/float32/imag' ); * * // Define the shape of the array: * var shape = [ 2, 2 ]; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d.js index 6117aba488a..1e6502cb9da 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d.js @@ -37,7 +37,7 @@ * var shape = [ 3, 1, 2 ]; * * // Define the array strides: -* var sx = [ 4, 4, 1 ]; +* var sx = [ 2, 2, 1 ]; * var sm = [ 2, 2, 1 ]; * var sy = [ 1 ]; * @@ -75,7 +75,7 @@ * mskfilter3d( x, mask, y ); * * console.log( y.data ); -* // => [ 2.0, 6.0, 10.0 ] +* // => [ 2.0, 4.0, 6.0 ] */ function mskfilter3d( x, mask, y ) { var xbuf; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_accessors.js index a168ddc1f98..e0aed33b32a 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_accessors.js @@ -33,15 +33,15 @@ * var BooleanArray = require( '@stdlib/array/bool' ); * var Complex64Array = require( '@stdlib/array/complex64' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); -* var realf = require( '@stdlib/complex/realf' ); -* var imagf = require( '@stdlib/complex/imagf' ); +* var realf = require( '@stdlib/complex/float32/real' ); +* var imagf = require( '@stdlib/complex/float32/imag' ); * * // Define the shape of the array: * var shape = [ 1, 2, 2 ]; * * // Define the array strides: -* var sx = [ 2, 2, 1 ]; -* var sm = [ 2, 2, 1 ]; +* var sx = [ 4, 2, 1 ]; +* var sm = [ 4, 2, 1 ]; * var sy = [ 1 ]; * * // Define the index offset: diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_blocked.js index 346868cd8cf..fffd15ff0b7 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_blocked.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_blocked.js @@ -45,7 +45,7 @@ var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); * var shape = [ 3, 1, 2 ]; * * // Define the array strides: -* var sx = [ 4, 4, 1 ]; +* var sx = [ 2, 2, 1 ]; * var sm = [ 2, 2, 1 ]; * var sy = [ 1 ]; * @@ -83,7 +83,7 @@ var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); * blockedmskfilter3d( x, mask, y ); * * console.log( y.data ); -* // => [ 2.0, 6.0, 10.0 ] +* // => [ 2.0, 4.0, 6.0 ] */ function blockedmskfilter3d( x, mask, y ) { var bsize; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_blocked_accessors.js index 94038d45bc9..0ca402f9b84 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_blocked_accessors.js @@ -41,15 +41,15 @@ var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); * var BooleanArray = require( '@stdlib/array/bool' ); * var Complex64Array = require( '@stdlib/array/complex64' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); -* var realf = require( '@stdlib/complex/realf' ); -* var imagf = require( '@stdlib/complex/imagf' ); +* var realf = require( '@stdlib/complex/float32/real' ); +* var imagf = require( '@stdlib/complex/float32/imag' ); * * // Define the shape of the array: * var shape = [ 1, 2, 2 ]; * * // Define the array strides: -* var sx = [ 2, 2, 1 ]; -* var sm = [ 2, 2, 1 ]; +* var sx = [ 4, 2, 1 ]; +* var sm = [ 4, 2, 1 ]; * var sy = [ 1 ]; * * // Define the index offset: diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d.js index d269def4db8..05769c7164a 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d.js @@ -37,7 +37,7 @@ * var shape = [ 1, 3, 1, 2 ]; * * // Define the array strides: -* var sx = [ 12, 4, 4, 1 ]; +* var sx = [ 6, 2, 2, 1 ]; * var sm = [ 6, 2, 2, 1 ]; * var sy = [ 1 ]; * @@ -75,7 +75,7 @@ * mskfilter4d( x, mask, y ); * * console.log( y.data ); -* // => [ 2.0, 6.0, 10.0 ] +* // => [ 2.0, 4.0, 6.0 ] */ function mskfilter4d( x, mask, y ) { var xbuf; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_accessors.js index 7b82ebe9854..db622109ff7 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_accessors.js @@ -33,15 +33,15 @@ * var BooleanArray = require( '@stdlib/array/bool' ); * var Complex64Array = require( '@stdlib/array/complex64' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); -* var realf = require( '@stdlib/complex/realf' ); -* var imagf = require( '@stdlib/complex/imagf' ); +* var realf = require( '@stdlib/complex/float32/real' ); +* var imagf = require( '@stdlib/complex/float32/imag' ); * * // Define the shape of the array: * var shape = [ 1, 1, 2, 2 ]; * * // Define the array strides: -* var sx = [ 2, 2, 2, 1 ]; -* var sm = [ 2, 2, 2, 1 ]; +* var sx = [ 4, 4, 2, 1 ]; +* var sm = [ 4, 4, 2, 1 ]; * var sy = [ 1 ]; * * // Define the index offset: diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_blocked.js index 22dd7b5f6f7..c4c840b9abe 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_blocked.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_blocked.js @@ -45,7 +45,7 @@ var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); * var shape = [ 1, 3, 1, 2 ]; * * // Define the array strides: -* var sx = [ 12, 4, 4, 1 ]; +* var sx = [ 6, 2, 2, 1 ]; * var sm = [ 6, 2, 2, 1 ]; * var sy = [ 1 ]; * @@ -83,7 +83,7 @@ var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); * blockedmskfilter4d( x, mask, y ); * * console.log( y.data ); -* // => [ 2.0, 6.0, 10.0 ] +* // => [ 2.0, 4.0, 6.0 ] */ function blockedmskfilter4d( x, mask, y ) { // eslint-disable-line max-statements var bsize; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_blocked_accessors.js index b8151eddcea..2dd09653212 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_blocked_accessors.js @@ -41,15 +41,15 @@ var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); * var BooleanArray = require( '@stdlib/array/bool' ); * var Complex64Array = require( '@stdlib/array/complex64' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); -* var realf = require( '@stdlib/complex/realf' ); -* var imagf = require( '@stdlib/complex/imagf' ); +* var realf = require( '@stdlib/complex/float32/real' ); +* var imagf = require( '@stdlib/complex/float32/imag' ); * * // Define the shape of the array: * var shape = [ 1, 1, 2, 2 ]; * * // Define the array strides: -* var sx = [ 2, 2, 2, 1 ]; -* var sm = [ 2, 2, 2, 1 ]; +* var sx = [ 4, 4, 2, 1 ]; +* var sm = [ 4, 4, 2, 1 ]; * var sy = [ 1 ]; * * // Define the index offset: diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d.js index b1e0467108a..1890064542c 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d.js @@ -39,7 +39,7 @@ * var shape = [ 1, 1, 3, 1, 2 ]; * * // Define the array strides: -* var sx = [ 12, 12, 4, 4, 1 ]; +* var sx = [ 6, 6, 2, 2, 1 ]; * var sm = [ 6, 6, 2, 2, 1 ]; * var sy = [ 1 ]; * @@ -77,7 +77,7 @@ * mskfilter5d( x, mask, y ); * * console.log( y.data ); -* // => [ 2.0, 6.0, 10.0 ] +* // => [ 2.0, 4.0, 6.0 ] */ function mskfilter5d( x, mask, y ) { var xbuf; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_accessors.js index 4307266f4a8..83c3f90bb48 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_accessors.js @@ -35,15 +35,15 @@ * var BooleanArray = require( '@stdlib/array/bool' ); * var Complex64Array = require( '@stdlib/array/complex64' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); -* var realf = require( '@stdlib/complex/realf' ); -* var imagf = require( '@stdlib/complex/imagf' ); +* var realf = require( '@stdlib/complex/float32/real' ); +* var imagf = require( '@stdlib/complex/float32/imag' ); * * // Define the shape of the array: * var shape = [ 1, 1, 1, 2, 2 ]; * * // Define the array strides: -* var sx = [ 2, 2, 2, 2, 1 ]; -* var sm = [ 2, 2, 2, 2, 1 ]; +* var sx = [ 4, 4, 4, 2, 1 ]; +* var sm = [ 4, 4, 4, 2, 1 ]; * var sy = [ 1 ]; * * // Define the index offset: diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_blocked.js index 96f9ab1db80..4392986f1e1 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_blocked.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_blocked.js @@ -45,7 +45,7 @@ var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); * var shape = [ 1, 1, 3, 1, 2 ]; * * // Define the array strides: -* var sx = [ 12, 12, 4, 4, 1 ]; +* var sx = [ 6, 6, 2, 2, 1 ]; * var sm = [ 6, 6, 2, 2, 1 ]; * var sy = [ 1 ]; * @@ -83,7 +83,7 @@ var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); * blockedmskfilter5d( x, mask, y ); * * console.log( y.data ); -* // => [ 2.0, 6.0, 10.0 ] +* // => [ 2.0, 4.0, 6.0 ] */ function blockedmskfilter5d( x, mask, y ) { // eslint-disable-line max-statements var bsize; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_blocked_accessors.js index 7756887ee69..6285f965f50 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_blocked_accessors.js @@ -41,15 +41,15 @@ var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); * var BooleanArray = require( '@stdlib/array/bool' ); * var Complex64Array = require( '@stdlib/array/complex64' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); -* var realf = require( '@stdlib/complex/realf' ); -* var imagf = require( '@stdlib/complex/imagf' ); +* var realf = require( '@stdlib/complex/float32/real' ); +* var imagf = require( '@stdlib/complex/float32/imag' ); * * // Define the shape of the array: * var shape = [ 1, 1, 1, 2, 2 ]; * * // Define the array strides: -* var sx = [ 2, 2, 2, 2, 1 ]; -* var sm = [ 2, 2, 2, 2, 1 ]; +* var sx = [ 4, 4, 4, 2, 1 ]; +* var sm = [ 4, 4, 4, 2, 1 ]; * var sy = [ 1 ]; * * // Define the index offset: diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d.js index 71033c9bf8d..2073b658e83 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d.js @@ -39,7 +39,7 @@ * var shape = [ 1, 1, 1, 3, 1, 2 ]; * * // Define the array strides: -* var sx = [ 12, 12, 12, 4, 4, 1 ]; +* var sx = [ 6, 6, 6, 2, 2, 1 ]; * var sm = [ 6, 6, 6, 2, 2, 1 ]; * var sy = [ 1 ]; * @@ -77,7 +77,7 @@ * mskfilter6d( x, mask, y ); * * console.log( y.data ); -* // => [ 2.0, 6.0, 10.0 ] +* // => [ 2.0, 4.0, 6.0 ] */ function mskfilter6d( x, mask, y ) { // eslint-disable-line max-statements var xbuf; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_accessors.js index f199457a9d1..1bebe783b18 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_accessors.js @@ -35,15 +35,15 @@ * var BooleanArray = require( '@stdlib/array/bool' ); * var Complex64Array = require( '@stdlib/array/complex64' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); -* var realf = require( '@stdlib/complex/realf' ); -* var imagf = require( '@stdlib/complex/imagf' ); +* var realf = require( '@stdlib/complex/float32/real' ); +* var imagf = require( '@stdlib/complex/float32/imag' ); * * // Define the shape of the array: * var shape = [ 1, 1, 1, 1, 2, 2 ]; * * // Define the array strides: -* var sx = [ 2, 2, 2, 2, 2, 1 ]; -* var sm = [ 2, 2, 2, 2, 2, 1 ]; +* var sx = [ 4, 4, 4, 4, 2, 1 ]; +* var sm = [ 4, 4, 4, 4, 2, 1 ]; * var sy = [ 1 ]; * * // Define the index offset: diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_blocked.js index 4eb7d1c7b25..2f6a97159ac 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_blocked.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_blocked.js @@ -45,7 +45,7 @@ var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); * var shape = [ 1, 1, 1, 3, 1, 2 ]; * * // Define the array strides: -* var sx = [ 12, 12, 12, 4, 4, 1 ]; +* var sx = [ 6, 6, 6, 2, 2, 1 ]; * var sm = [ 6, 6, 6, 2, 2, 1 ]; * var sy = [ 1 ]; * @@ -83,7 +83,7 @@ var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); * blockedmskfilter6d( x, mask, y ); * * console.log( y.data ); -* // => [ 2.0, 6.0, 10.0 ] +* // => [ 2.0, 4.0, 6.0 ] */ function blockedmskfilter6d( x, mask, y ) { // eslint-disable-line max-statements var bsize; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_blocked_accessors.js index 4179af76d28..5558da34356 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_blocked_accessors.js @@ -41,15 +41,15 @@ var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); * var BooleanArray = require( '@stdlib/array/bool' ); * var Complex64Array = require( '@stdlib/array/complex64' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); -* var realf = require( '@stdlib/complex/realf' ); -* var imagf = require( '@stdlib/complex/imagf' ); +* var realf = require( '@stdlib/complex/float32/real' ); +* var imagf = require( '@stdlib/complex/float32/imag' ); * * // Define the shape of the array: * var shape = [ 1, 1, 1, 1, 2, 2 ]; * * // Define the array strides: -* var sx = [ 2, 2, 2, 2, 2, 1 ]; -* var sm = [ 2, 2, 2, 2, 2, 1 ]; +* var sx = [ 4, 4, 4, 4, 2, 1 ]; +* var sm = [ 4, 4, 4, 4, 2, 1 ]; * var sy = [ 1 ]; * * // Define the index offset: diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d.js index c8e45d29582..b0c33d83a05 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d.js @@ -39,7 +39,7 @@ * var shape = [ 1, 1, 1, 1, 3, 1, 2 ]; * * // Define the array strides: -* var sx = [ 12, 12, 12, 12, 4, 4, 1 ]; +* var sx = [ 6, 6, 6, 6, 2, 2, 1 ]; * var sm = [ 6, 6, 6, 6, 2, 2, 1 ]; * var sy = [ 1 ]; * @@ -77,7 +77,7 @@ * mskfilter7d( x, mask, y ); * * console.log( y.data ); -* // => [ 2.0, 6.0, 10.0 ] +* // => [ 2.0, 4.0, 6.0 ] */ function mskfilter7d( x, mask, y ) { // eslint-disable-line max-statements var xbuf; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_accessors.js index 6d9dda1e2a9..8392c4f6150 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_accessors.js @@ -35,15 +35,15 @@ * var BooleanArray = require( '@stdlib/array/bool' ); * var Complex64Array = require( '@stdlib/array/complex64' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); -* var realf = require( '@stdlib/complex/realf' ); -* var imagf = require( '@stdlib/complex/imagf' ); +* var realf = require( '@stdlib/complex/float32/real' ); +* var imagf = require( '@stdlib/complex/float32/imag' ); * * // Define the shape of the array: * var shape = [ 1, 1, 1, 1, 1, 2, 2 ]; * * // Define the array strides: -* var sx = [ 2, 2, 2, 2, 2, 2, 1 ]; -* var sm = [ 2, 2, 2, 2, 2, 2, 1 ]; +* var sx = [ 4, 4, 4, 4, 4, 2, 1 ]; +* var sm = [ 4, 4, 4, 4, 4, 2, 1 ]; * var sy = [ 1 ]; * * // Define the index offset: diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_blocked.js index 2cc89d61350..d9a29b5e749 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_blocked.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_blocked.js @@ -45,7 +45,7 @@ var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); * var shape = [ 1, 1, 1, 1, 3, 1, 2 ]; * * // Define the array strides: -* var sx = [ 12, 12, 12, 12, 4, 4, 1 ]; +* var sx = [ 6, 6, 6, 6, 2, 2, 1 ]; * var sm = [ 6, 6, 6, 6, 2, 2, 1 ]; * var sy = [ 1 ]; * @@ -83,7 +83,7 @@ var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); * blockedmskfilter7d( x, mask, y ); * * console.log( y.data ); -* // => [ 2.0, 6.0, 10.0 ] +* // => [ 2.0, 4.0, 6.0 ] */ function blockedmskfilter7d( x, mask, y ) { // eslint-disable-line max-statements var bsize; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_blocked_accessors.js index 05941d7e5c6..86062f04b92 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_blocked_accessors.js @@ -41,15 +41,15 @@ var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); * var BooleanArray = require( '@stdlib/array/bool' ); * var Complex64Array = require( '@stdlib/array/complex64' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); -* var realf = require( '@stdlib/complex/realf' ); -* var imagf = require( '@stdlib/complex/imagf' ); +* var realf = require( '@stdlib/complex/float32/real' ); +* var imagf = require( '@stdlib/complex/float32/imag' ); * * // Define the shape of the array: * var shape = [ 1, 1, 1, 1, 1, 2, 2 ]; * * // Define the array strides: -* var sx = [ 2, 2, 2, 2, 2, 2, 1 ]; -* var sm = [ 2, 2, 2, 2, 2, 2, 1 ]; +* var sx = [ 4, 4, 4, 4, 4, 2, 1 ]; +* var sm = [ 4, 4, 4, 4, 4, 2, 1 ]; * var sy = [ 1 ]; * * // Define the index offset: diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d.js index 9ceb2462658..e6d7cba8e27 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d.js @@ -39,7 +39,7 @@ * var shape = [ 1, 1, 1, 1, 1, 3, 1, 2 ]; * * // Define the array strides: -* var sx = [ 12, 12, 12, 12, 12, 4, 4, 1 ]; +* var sx = [ 6, 6, 6, 6, 6, 2, 2, 1 ]; * var sm = [ 6, 6, 6, 6, 6, 2, 2, 1 ]; * var sy = [ 1 ]; * @@ -77,7 +77,7 @@ * mskfilter8d( x, mask, y ); * * console.log( y.data ); -* // => [ 2.0, 6.0, 10.0 ] +* // => [ 2.0, 4.0, 6.0 ] */ function mskfilter8d( x, mask, y ) { // eslint-disable-line max-statements var xbuf; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_accessors.js index c5b0350c58a..29bac68ee50 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_accessors.js @@ -35,15 +35,15 @@ * var BooleanArray = require( '@stdlib/array/bool' ); * var Complex64Array = require( '@stdlib/array/complex64' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); -* var realf = require( '@stdlib/complex/realf' ); -* var imagf = require( '@stdlib/complex/imagf' ); +* var realf = require( '@stdlib/complex/float32/real' ); +* var imagf = require( '@stdlib/complex/float32/imag' ); * * // Define the shape of the array: * var shape = [ 1, 1, 1, 1, 1, 1, 2, 2 ]; * * // Define the array strides: -* var sx = [ 2, 2, 2, 2, 2, 2, 2, 1 ]; -* var sm = [ 2, 2, 2, 2, 2, 2, 2, 1 ]; +* var sx = [ 4, 4, 4, 4, 4, 4, 2, 1 ]; +* var sm = [ 4, 4, 4, 4, 4, 4, 2, 1 ]; * var sy = [ 1 ]; * * // Define the index offset: diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_blocked.js index 7b83585b053..7474bc16450 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_blocked.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_blocked.js @@ -45,7 +45,7 @@ var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); * var shape = [ 1, 1, 1, 1, 1, 3, 1, 2 ]; * * // Define the array strides: -* var sx = [ 12, 12, 12, 12, 12, 4, 4, 1 ]; +* var sx = [ 6, 6, 6, 6, 6, 2, 2, 1 ]; * var sm = [ 6, 6, 6, 6, 6, 2, 2, 1 ]; * var sy = [ 1 ]; * @@ -83,7 +83,7 @@ var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); * blockedmskfilter8d( x, mask, y ); * * console.log( y.data ); -* // => [ 2.0, 6.0, 10.0 ] +* // => [ 2.0, 4.0, 6.0 ] */ function blockedmskfilter8d( x, mask, y ) { // eslint-disable-line max-statements, max-lines-per-function var bsize; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_blocked_accessors.js index 815f4999d82..b9328ed462f 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_blocked_accessors.js @@ -41,15 +41,15 @@ var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); * var BooleanArray = require( '@stdlib/array/bool' ); * var Complex64Array = require( '@stdlib/array/complex64' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); -* var realf = require( '@stdlib/complex/realf' ); -* var imagf = require( '@stdlib/complex/imagf' ); +* var realf = require( '@stdlib/complex/float32/real' ); +* var imagf = require( '@stdlib/complex/float32/imag' ); * * // Define the shape of the array: * var shape = [ 1, 1, 1, 1, 1, 1, 2, 2 ]; * * // Define the array strides: -* var sx = [ 2, 2, 2, 2, 2, 2, 2, 1 ]; -* var sm = [ 2, 2, 2, 2, 2, 2, 2, 1 ]; +* var sx = [ 4, 4, 4, 4, 4, 4, 2, 1 ]; +* var sm = [ 4, 4, 4, 4, 4, 4, 2, 1 ]; * var sy = [ 1 ]; * * // Define the index offset: diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d.js index 509580e2aff..1bbe0f1f477 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d.js @@ -39,7 +39,7 @@ * var shape = [ 1, 1, 1, 1, 1, 1, 3, 1, 2 ]; * * // Define the array strides: -* var sx = [ 12, 12, 12, 12, 12, 12, 4, 4, 1 ]; +* var sx = [ 6, 6, 6, 6, 6, 6, 2, 2, 1 ]; * var sm = [ 6, 6, 6, 6, 6, 6, 2, 2, 1 ]; * var sy = [ 1 ]; * @@ -77,7 +77,7 @@ * mskfilter9d( x, mask, y ); * * console.log( y.data ); -* // => [ 2.0, 6.0, 10.0 ] +* // => [ 2.0, 4.0, 6.0 ] */ function mskfilter9d( x, mask, y ) { // eslint-disable-line max-statements var xbuf; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_accessors.js index 9b8cc59c1a3..d89af4eac8f 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_accessors.js @@ -35,15 +35,15 @@ * var BooleanArray = require( '@stdlib/array/bool' ); * var Complex64Array = require( '@stdlib/array/complex64' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); -* var realf = require( '@stdlib/complex/realf' ); -* var imagf = require( '@stdlib/complex/imagf' ); +* var realf = require( '@stdlib/complex/float32/real' ); +* var imagf = require( '@stdlib/complex/float32/imag' ); * * // Define the shape of the array: * var shape = [ 1, 1, 1, 1, 1, 1, 1, 2, 2 ]; * * // Define the array strides: -* var sx = [ 2, 2, 2, 2, 2, 2, 2, 2, 1 ]; -* var sm = [ 2, 2, 2, 2, 2, 2, 2, 2, 1 ]; +* var sx = [ 4, 4, 4, 4, 4, 4, 4, 2, 1 ]; +* var sm = [ 4, 4, 4, 4, 4, 4, 4, 2, 1 ]; * var sy = [ 1 ]; * * // Define the index offset: diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_blocked.js index 7712036cef2..d8c73453b90 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_blocked.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_blocked.js @@ -45,7 +45,7 @@ var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); * var shape = [ 1, 1, 1, 1, 1, 1, 3, 1, 2 ]; * * // Define the array strides: -* var sx = [ 12, 12, 12, 12, 12, 12, 4, 4, 1 ]; +* var sx = [ 6, 6, 6, 6, 6, 6, 2, 2, 1 ]; * var sm = [ 6, 6, 6, 6, 6, 6, 2, 2, 1 ]; * var sy = [ 1 ]; * @@ -83,7 +83,7 @@ var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); * blockedmskfilter9d( x, mask, y ); * * console.log( y.data ); -* // => [ 2.0, 6.0, 10.0 ] +* // => [ 2.0, 4.0, 6.0 ] */ function blockedmskfilter9d( x, mask, y ) { // eslint-disable-line max-statements, max-lines-per-function var bsize; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_blocked_accessors.js index c6bef507bb9..06d8003403e 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_blocked_accessors.js @@ -41,15 +41,15 @@ var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); * var BooleanArray = require( '@stdlib/array/bool' ); * var Complex64Array = require( '@stdlib/array/complex64' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); -* var realf = require( '@stdlib/complex/realf' ); -* var imagf = require( '@stdlib/complex/imagf' ); +* var realf = require( '@stdlib/complex/float32/real' ); +* var imagf = require( '@stdlib/complex/float32/imag' ); * * // Define the shape of the array: * var shape = [ 1, 1, 1, 1, 1, 1, 1, 2, 2 ]; * * // Define the array strides: -* var sx = [ 2, 2, 2, 2, 2, 2, 2, 2, 1 ]; -* var sm = [ 2, 2, 2, 2, 2, 2, 2, 2, 1 ]; +* var sx = [ 4, 4, 4, 4, 4, 4, 4, 2, 1 ]; +* var sm = [ 4, 4, 4, 4, 4, 4, 4, 2, 1 ]; * var sy = [ 1 ]; * * // Define the index offset: diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/index.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/index.js index 1848a8768a7..9cd35a7eda8 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/index.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/index.js @@ -32,7 +32,7 @@ * var shape = [ 3, 1, 2 ]; * * // Define the array strides: -* var sx = [ 4, 4, 1 ]; +* var sx = [ 2, 2, 1 ]; * var sm = [ 2, 2, 1 ]; * var sy = [ 1 ]; * @@ -69,7 +69,7 @@ * mskfilter( [ x, mask, out ] ); * * console.log( out.data ); -* // => [ 2.0, 6.0, 10.0 ] +* // => [ 2.0, 4.0, 6.0 ] */ // MODULES // diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js index 9de91eca315..6df099f2522 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js @@ -158,7 +158,7 @@ var MAX_DIMS = MSKFILTER.length - 1; * var shape = [ 3, 1, 2 ]; * * // Define the array strides: -* var sx = [ 4, 4, 1 ]; +* var sx = [ 2, 2, 1 ]; * var sm = [ 2, 2, 1 ]; * var sy = [ 1 ]; * @@ -195,7 +195,7 @@ var MAX_DIMS = MSKFILTER.length - 1; * mskfilter( [ x, mask, out ] ); * * console.log( out.data ); -* // => [ 2.0, 6.0, 10.0 ] +* // => [ 2.0, 4.0, 6.0 ] */ function mskfilter( arrays ) { var ndims; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/nd.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/nd.js index ab9f6005b2f..5a99d754a3c 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/nd.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/nd.js @@ -48,7 +48,7 @@ var MODE = 'throw'; * var shape = [ 2, 2 ]; * * // Define the array strides: -* var sx = [ 4, 1 ]; +* var sx = [ 2, 1 ]; * var sm = [ 2, 1 ]; * var sy = [ 1 ]; * @@ -86,7 +86,7 @@ var MODE = 'throw'; * mskfilternd( x, mask, y ); * * console.log( y.data ); -* // => [ 2.0, 6.0 ] +* // => [ 2.0, 4.0 ] */ function mskfilternd( x, mask, y ) { var xbuf; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/nd_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/nd_accessors.js index 9f98e02a7db..2ec3f457125 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/nd_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/nd_accessors.js @@ -44,8 +44,8 @@ var MODE = 'throw'; * var BooleanArray = require( '@stdlib/array/bool' ); * var Complex64Array = require( '@stdlib/array/complex64' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); -* var realf = require( '@stdlib/complex/realf' ); -* var imagf = require( '@stdlib/complex/imagf' ); +* var realf = require( '@stdlib/complex/float32/real' ); +* var imagf = require( '@stdlib/complex/float32/imag' ); * * // Define the shape of the array: * var shape = [ 2, 2 ]; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/package.json b/lib/node_modules/@stdlib/ndarray/base/mskfilter/package.json index 64b8e552732..fa72dc5a5c3 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/package.json +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/package.json @@ -1,63 +1,63 @@ { - "name": "@stdlib/ndarray/base/mskfilter", - "version": "0.0.0", - "description": "Apply a mask to a provided input ndarray and assign unmasked values to elements in a provided one-dimensional output ndarray.", - "license": "Apache-2.0", - "author": { + "name": "@stdlib/ndarray/base/mskfilter", + "version": "0.0.0", + "description": "Apply a mask to a provided input ndarray and assign unmasked values to elements in a provided one-dimensional 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" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "include": "./include", - "lib": "./lib", - "scripts": "./scripts", - "src": "./src", - "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", - "mskfilter" - ], - "__stdlib__": {} - } \ No newline at end of file + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "include": "./include", + "lib": "./lib", + "scripts": "./scripts", + "src": "./src", + "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", + "mskfilter" + ], + "__stdlib__": {} +} From db07de82f5a737470a383596f4ad223db12887ce Mon Sep 17 00:00:00 2001 From: Jaysukh-409 Date: Sat, 10 Aug 2024 17:29:17 +0530 Subject: [PATCH 20/34] test: add tests for 0d ndarray --- .../ndarray/base/mskfilter/lib/main.js | 12 +-- .../ndarray/base/mskfilter/test/test.0d.js | 98 +++++++++++++++++++ 2 files changed, 104 insertions(+), 6 deletions(-) create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.0d.js diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js index 6df099f2522..e416380cbfc 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js @@ -253,12 +253,6 @@ function mskfilter( arrays ) { throw new Error( 'invalid arguments. Input and output arrays must have the same data type. dtype(x) == %s. dtype(y) == %s', x.dtype, y.dtype ); } - // Check whether we were provided an empty input ndarray... - len = numel( shx ); - if ( len === 0 ) { - return; - } - // Determine whether we can avoid iteration altogether... if ( ndims === 0 ) { if ( x.accessorProtocol || mask.accessorProtocol || y.accessorProtocol ) { @@ -267,6 +261,12 @@ function mskfilter( arrays ) { return MSKFILTER[ ndims ]( x, mask, y ); } + // Check whether we were provided an empty input ndarray... + len = numel( shx ); + if ( len === 0 ) { + return; + } + // Determine whether the ndarrays are one-dimensional and thus readily translate to one-dimensional strided arrays... if ( ndims === 1 ) { if ( x.accessorProtocol || mask.accessorProtocol || y.accessorProtocol ) { diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.0d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.0d.js new file mode 100644 index 00000000000..9a885b69120 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.0d.js @@ -0,0 +1,98 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); +var isSameFloat64Array = require( '@stdlib/assert/is-same-float64array' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var BooleanArray = require( '@stdlib/array/bool' ); +var Uint8Array = require( '@stdlib/array/uint8' ); +var Float64Array = require( '@stdlib/array/float64' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var mskfilter = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof mskfilter, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function applies a mask to a provided 0-dimensional ndarray input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray', function test( t ) { + var expected; + var mask; + var x; + var y; + + // mask having truthy value + x = new ndarray( 'float64', new Float64Array( [ 5.0 ] ), [], [ 0 ], 0, 'row-major' ); + mask = new ndarray( 'uint8', new Uint8Array( [ 1 ] ), [], [ 0 ], 0, 'row-major' ); + y = new ndarray( 'float64', new Float64Array( [ 0.0 ] ), [ 1 ], [ 0 ], 0, 'row-major' ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 5.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + // mask having falsy value + x = new ndarray( 'float64', new Float64Array( [ 5.0 ] ), [], [ 0 ], 0, 'row-major' ); + mask = new ndarray( 'uint8', new Uint8Array( [ 0 ] ), [], [ 0 ], 0, 'row-major' ); + y = new ndarray( 'float64', new Float64Array( [ 0.0 ] ), [ 1 ], [ 0 ], 0, 'row-major' ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 0.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 0-dimensional ndarray input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (accessors)', function test( t ) { + var expected; + var mask; + var x; + var y; + + // mask having truthy value + x = new ndarray( 'complex64', new Complex64Array( [ 5.0, 5.0 ] ), [], [ 0 ], 0, 'row-major' ); + mask = new ndarray( 'bool', new BooleanArray( [ 1 ] ), [], [ 0 ], 0, 'row-major' ); + y = new ndarray( 'complex64', new Complex64Array( [ 0.0, 0.0 ] ), [ 1 ], [ 0 ], 0, 'row-major' ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 5.0, 5.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + // mask having falsy value + x = new ndarray( 'complex64', new Complex64Array( [ 5.0, 5.0 ] ), [], [ 0 ], 0, 'row-major' ); + mask = new ndarray( 'bool', new BooleanArray( [ 0 ] ), [], [ 0 ], 0, 'row-major' ); + y = new ndarray( 'complex64', new Complex64Array( [ 0.0, 0.0 ] ), [ 1 ], [ 0 ], 0, 'row-major' ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 0.0, 0.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); From da8146109f150c37d77fc82e2021a8ebb2674b93 Mon Sep 17 00:00:00 2001 From: Jaysukh-409 Date: Sat, 10 Aug 2024 22:16:50 +0530 Subject: [PATCH 21/34] test: add tests for 1d ndarray --- .../ndarray/base/mskfilter/test/test.0d.js | 4 +- .../ndarray/base/mskfilter/test/test.1d.js | 76 +++++++++++++++++++ .../ndarray/base/mskfilter/test/test.js | 33 ++++++++ 3 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.1d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.js diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.0d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.0d.js index 9a885b69120..8058e1abcc8 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.0d.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.0d.js @@ -39,7 +39,7 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function applies a mask to a provided 0-dimensional ndarray input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray', function test( t ) { +tape( 'the function applies a mask to a provided 0-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray', function test( t ) { var expected; var mask; var x; @@ -68,7 +68,7 @@ tape( 'the function applies a mask to a provided 0-dimensional ndarray input nda t.end(); }); -tape( 'the function applies a mask to a provided 0-dimensional ndarray input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (accessors)', function test( t ) { +tape( 'the function applies a mask to a provided 0-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (accessors)', function test( t ) { var expected; var mask; var x; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.1d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.1d.js new file mode 100644 index 00000000000..58b08239222 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.1d.js @@ -0,0 +1,76 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); +var isSameFloat64Array = require( '@stdlib/assert/is-same-float64array' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Uint8Array = require( '@stdlib/array/uint8' ); +var BooleanArray = require( '@stdlib/array/bool' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var mskfilter = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof mskfilter, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function applies a mask to a provided 1-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray', function test( t ) { + var expected; + var mask; + var x; + var y; + + x = new ndarray( 'float64', new Float64Array( [ 1.0, 2.0, 3.0 ] ), [ 3 ], [ 1 ], 0, 'row-major' ); + mask = new ndarray( 'uint8', new Uint8Array( [ 1, 0, 1 ] ), [ 3 ], [ 1 ], 0, 'row-major' ); + y = new ndarray( 'float64', new Float64Array( [ 0.0, 0.0 ] ), [ 2 ], [ 1 ], 0, 'row-major' ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 1-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (accessors)', function test( t ) { + var expected; + var mask; + var x; + var y; + + x = new ndarray( 'complex64', new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ), [ 3 ], [ 1 ], 0, 'row-major' ); + mask = new ndarray( 'bool', new BooleanArray( [ 1, 0, 1 ] ), [ 3 ], [ 1 ], 0, 'row-major' ); + y = new ndarray( 'complex64', new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ), [ 2 ], [ 1 ], 0, 'row-major' ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.js new file mode 100644 index 00000000000..4b182ac6d40 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.js @@ -0,0 +1,33 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var mskfilter = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof mskfilter, 'function', 'main export is a function' ); + t.end(); +}); From 7515b008bbd4de3b9bc43d4bdbc503913bb635bb Mon Sep 17 00:00:00 2001 From: Jaysukh-409 Date: Tue, 13 Aug 2024 21:19:55 +0530 Subject: [PATCH 22/34] bench: add benchmark files --- .../benchmark.10d_blocked_columnmajor.js | 154 ++++++++++++++ .../benchmark.10d_blocked_rowmajor.js | 154 ++++++++++++++ .../benchmark/benchmark.10d_columnmajor.js | 154 ++++++++++++++ .../benchmark/benchmark.10d_rowmajor.js | 154 ++++++++++++++ .../benchmark/benchmark.11d_columnmajor.js | 154 ++++++++++++++ .../benchmark/benchmark.11d_rowmajor.js | 154 ++++++++++++++ .../benchmark/benchmark.1d_columnmajor.js | 143 +++++++++++++ .../benchmark/benchmark.1d_rowmajor.js | 143 +++++++++++++ .../benchmark.2d_blocked_columnmajor.js | 155 ++++++++++++++ .../benchmark.2d_blocked_rowmajor.js | 155 ++++++++++++++ .../benchmark/benchmark.2d_columnmajor.js | 155 ++++++++++++++ .../benchmark/benchmark.2d_rowmajor.js | 155 ++++++++++++++ .../benchmark.2d_rowmajor_accessors.js | 185 +++++++++++++++++ ...benchmark.2d_rowmajor_accessors_complex.js | 194 ++++++++++++++++++ .../benchmark.3d_blocked_columnmajor.js | 155 ++++++++++++++ .../benchmark.3d_blocked_rowmajor.js | 155 ++++++++++++++ .../benchmark/benchmark.3d_columnmajor.js | 155 ++++++++++++++ .../benchmark/benchmark.3d_rowmajor.js | 155 ++++++++++++++ .../benchmark.4d_blocked_columnmajor.js | 154 ++++++++++++++ .../benchmark.4d_blocked_rowmajor.js | 154 ++++++++++++++ .../benchmark/benchmark.4d_columnmajor.js | 154 ++++++++++++++ .../benchmark/benchmark.4d_rowmajor.js | 154 ++++++++++++++ .../benchmark.5d_blocked_columnmajor.js | 154 ++++++++++++++ .../benchmark.5d_blocked_rowmajor.js | 154 ++++++++++++++ .../benchmark/benchmark.5d_columnmajor.js | 154 ++++++++++++++ .../benchmark/benchmark.5d_rowmajor.js | 154 ++++++++++++++ .../benchmark.6d_blocked_columnmajor.js | 154 ++++++++++++++ .../benchmark.6d_blocked_rowmajor.js | 154 ++++++++++++++ .../benchmark/benchmark.6d_columnmajor.js | 154 ++++++++++++++ .../benchmark/benchmark.6d_rowmajor.js | 154 ++++++++++++++ .../benchmark.7d_blocked_columnmajor.js | 154 ++++++++++++++ .../benchmark.7d_blocked_rowmajor.js | 154 ++++++++++++++ .../benchmark/benchmark.7d_columnmajor.js | 154 ++++++++++++++ .../benchmark/benchmark.7d_rowmajor.js | 154 ++++++++++++++ .../benchmark.8d_blocked_columnmajor.js | 154 ++++++++++++++ .../benchmark.8d_blocked_rowmajor.js | 154 ++++++++++++++ .../benchmark/benchmark.8d_columnmajor.js | 154 ++++++++++++++ .../benchmark/benchmark.8d_rowmajor.js | 154 ++++++++++++++ .../benchmark.9d_blocked_columnmajor.js | 154 ++++++++++++++ .../benchmark.9d_blocked_rowmajor.js | 154 ++++++++++++++ .../benchmark/benchmark.9d_columnmajor.js | 154 ++++++++++++++ .../benchmark/benchmark.9d_rowmajor.js | 154 ++++++++++++++ 42 files changed, 6525 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.10d_blocked_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.10d_blocked_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.10d_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.10d_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.11d_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.11d_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.1d_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.1d_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.2d_blocked_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.2d_blocked_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.2d_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.2d_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.2d_rowmajor_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.2d_rowmajor_accessors_complex.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.3d_blocked_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.3d_blocked_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.3d_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.3d_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.4d_blocked_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.4d_blocked_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.4d_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.4d_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.5d_blocked_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.5d_blocked_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.5d_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.5d_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.6d_blocked_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.6d_blocked_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.6d_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.6d_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.7d_blocked_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.7d_blocked_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.7d_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.7d_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.8d_blocked_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.8d_blocked_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.8d_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.8d_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.9d_blocked_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.9d_blocked_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.9d_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.9d_rowmajor.js diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.10d_blocked_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.10d_blocked_columnmajor.js new file mode 100644 index 00000000000..3d13ad68f05 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.10d_blocked_columnmajor.js @@ -0,0 +1,154 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var filledarray = require( '@stdlib/array/filled' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var mskfilter = require( './../lib/10d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} dtype - input and output ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, dtype ) { + var mask; + var x; + var y; + + x = filledarrayBy( len, dtype, discreteUniform( -100, 100 ) ); + mask = filledarrayBy( len, 'uint8', discreteUniform( 0, 1 ) ); + y = filledarray( 0.0, len, dtype ); + x = { + 'dtype': dtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + mask = { + 'dtype': 'uint8', + 'data': mask, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + y = { + 'dtype': dtype, + 'data': y, + 'shape': [ len ], + 'strides': [ 1 ], + 'offset': 0, + 'order': order + }; + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mskfilter( x, mask, y ); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var sh; + var t; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1, 1, 1, 1, 1, 1 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + len = floor( pow( len, 1.0/10.0 ) ); + sh = [ len, len, len, len, len, len, len, len, len, len ]; + len *= pow( len, 9 ); + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.10d_blocked_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.10d_blocked_rowmajor.js new file mode 100644 index 00000000000..6abca8787d4 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.10d_blocked_rowmajor.js @@ -0,0 +1,154 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var filledarray = require( '@stdlib/array/filled' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var mskfilter = require( './../lib/10d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} dtype - input and output ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, dtype ) { + var mask; + var x; + var y; + + x = filledarrayBy( len, dtype, discreteUniform( -100, 100 ) ); + mask = filledarrayBy( len, 'uint8', discreteUniform( 0, 1 ) ); + y = filledarray( 0.0, len, dtype ); + x = { + 'dtype': dtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + mask = { + 'dtype': 'uint8', + 'data': mask, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + y = { + 'dtype': dtype, + 'data': y, + 'shape': [ len ], + 'strides': [ 1 ], + 'offset': 0, + 'order': order + }; + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mskfilter( x, mask, y ); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var sh; + var t; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1, 1, 1, 1, 1, 1 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + len = floor( pow( len, 1.0/10.0 ) ); + sh = [ len, len, len, len, len, len, len, len, len, len ]; + len *= pow( len, 9 ); + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.10d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.10d_columnmajor.js new file mode 100644 index 00000000000..0d3140a2ef2 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.10d_columnmajor.js @@ -0,0 +1,154 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var filledarray = require( '@stdlib/array/filled' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var mskfilter = require( './../lib/10d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} dtype - input and output ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, dtype ) { + var mask; + var x; + var y; + + x = filledarrayBy( len, dtype, discreteUniform( -100, 100 ) ); + mask = filledarrayBy( len, 'uint8', discreteUniform( 0, 1 ) ); + y = filledarray( 0.0, len, dtype ); + x = { + 'dtype': dtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + mask = { + 'dtype': 'uint8', + 'data': mask, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + y = { + 'dtype': dtype, + 'data': y, + 'shape': [ len ], + 'strides': [ 1 ], + 'offset': 0, + 'order': order + }; + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mskfilter( x, mask, y ); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var sh; + var t; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1, 1, 1, 1, 1, 1 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + len = floor( pow( len, 1.0/10.0 ) ); + sh = [ len, len, len, len, len, len, len, len, len, len ]; + len *= pow( len, 9 ); + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.10d_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.10d_rowmajor.js new file mode 100644 index 00000000000..5dcc9085d36 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.10d_rowmajor.js @@ -0,0 +1,154 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var filledarray = require( '@stdlib/array/filled' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var mskfilter = require( './../lib/10d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} dtype - input and output ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, dtype ) { + var mask; + var x; + var y; + + x = filledarrayBy( len, dtype, discreteUniform( -100, 100 ) ); + mask = filledarrayBy( len, 'uint8', discreteUniform( 0, 1 ) ); + y = filledarray( 0.0, len, dtype ); + x = { + 'dtype': dtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + mask = { + 'dtype': 'uint8', + 'data': mask, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + y = { + 'dtype': dtype, + 'data': y, + 'shape': [ len ], + 'strides': [ 1 ], + 'offset': 0, + 'order': order + }; + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mskfilter( x, mask, y ); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var sh; + var t; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1, 1, 1, 1, 1, 1 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + len = floor( pow( len, 1.0/10.0 ) ); + sh = [ len, len, len, len, len, len, len, len, len, len ]; + len *= pow( len, 9 ); + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.11d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.11d_columnmajor.js new file mode 100644 index 00000000000..dcc9810f77c --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.11d_columnmajor.js @@ -0,0 +1,154 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var filledarray = require( '@stdlib/array/filled' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var mskfilter = require( './../lib/nd.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} dtype - input and output ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, dtype ) { + var mask; + var x; + var y; + + x = filledarrayBy( len, dtype, discreteUniform( -100, 100 ) ); + mask = filledarrayBy( len, 'uint8', discreteUniform( 0, 1 ) ); + y = filledarray( 0.0, len, dtype ); + x = { + 'dtype': dtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + mask = { + 'dtype': 'uint8', + 'data': mask, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + y = { + 'dtype': dtype, + 'data': y, + 'shape': [ len ], + 'strides': [ 1 ], + 'offset': 0, + 'order': order + }; + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mskfilter( x, mask, y ); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var sh; + var t; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + len = floor( pow( len, 1.0/11.0 ) ); + sh = [ len, len, len, len, len, len, len, len, len, len, len ]; + len *= pow( len, 10 ); + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.11d_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.11d_rowmajor.js new file mode 100644 index 00000000000..facb902070f --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.11d_rowmajor.js @@ -0,0 +1,154 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var filledarray = require( '@stdlib/array/filled' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var mskfilter = require( './../lib/nd.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} dtype - input and output ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, dtype ) { + var mask; + var x; + var y; + + x = filledarrayBy( len, dtype, discreteUniform( -100, 100 ) ); + mask = filledarrayBy( len, 'uint8', discreteUniform( 0, 1 ) ); + y = filledarray( 0.0, len, dtype ); + x = { + 'dtype': dtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + mask = { + 'dtype': 'uint8', + 'data': mask, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + y = { + 'dtype': dtype, + 'data': y, + 'shape': [ len ], + 'strides': [ 1 ], + 'offset': 0, + 'order': order + }; + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mskfilter( x, mask, y ); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var sh; + var t; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + len = floor( pow( len, 1.0/11.0 ) ); + sh = [ len, len, len, len, len, len, len, len, len, len, len ]; + len *= pow( len, 10 ); + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.1d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.1d_columnmajor.js new file mode 100644 index 00000000000..a738ff28490 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.1d_columnmajor.js @@ -0,0 +1,143 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var filledarray = require( '@stdlib/array/filled' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var mskfilter = require( './../lib' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} dtype - input and output ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, dtype ) { + var mask; + var x; + var y; + + x = filledarrayBy( len, dtype, discreteUniform( -100, 100 ) ); + mask = filledarrayBy( len, 'uint8', discreteUniform( 0, 1 ) ); + y = filledarray( 0.0, len, dtype ); + x = { + 'dtype': dtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + mask = { + 'dtype': 'uint8', + 'data': mask, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + y = { + 'dtype': dtype, + 'data': y, + 'shape': [ len ], + 'strides': [ 1], + 'offset': 0, + 'order': order + }; + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mskfilter( [ x, mask, y ] ); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var sh; + var t; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len ]; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.1d_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.1d_rowmajor.js new file mode 100644 index 00000000000..5d4f0c1268a --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.1d_rowmajor.js @@ -0,0 +1,143 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var filledarray = require( '@stdlib/array/filled' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var mskfilter = require( './../lib' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} dtype - input and output ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, dtype ) { + var mask; + var x; + var y; + + x = filledarrayBy( len, dtype, discreteUniform( -100, 100 ) ); + mask = filledarrayBy( len, 'uint8', discreteUniform( 0, 1 ) ); + y = filledarray( 0.0, len, dtype ); + x = { + 'dtype': dtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + mask = { + 'dtype': 'uint8', + 'data': mask, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + y = { + 'dtype': dtype, + 'data': y, + 'shape': [ len ], + 'strides': [ 1 ], + 'offset': 0, + 'order': order + }; + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mskfilter( [ x, mask, y ] ); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var sh; + var t; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len ]; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.2d_blocked_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.2d_blocked_columnmajor.js new file mode 100644 index 00000000000..7a1c687ec30 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.2d_blocked_columnmajor.js @@ -0,0 +1,155 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var sqrt = require( '@stdlib/math/base/special/sqrt' ); +var filledarray = require( '@stdlib/array/filled' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var mskfilter = require( './../lib/2d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} dtype - input and output ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, dtype ) { + var mask; + var x; + var y; + + x = filledarrayBy( len, dtype, discreteUniform( -100, 100 ) ); + mask = filledarrayBy( len, 'uint8', discreteUniform( 0, 1 ) ); + y = filledarray( 0.0, len, dtype ); + x = { + 'dtype': dtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + mask = { + 'dtype': 'uint8', + 'data': mask, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + y = { + 'dtype': dtype, + 'data': y, + 'shape': [ len ], + 'strides': [ 1 ], + 'offset': 0, + 'order': order + }; + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mskfilter( x, mask, y ); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var sh; + var t; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + sh = [ 2, len/2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + len = floor( sqrt( len ) ); + sh = [ len, len ]; + len *= len; + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.2d_blocked_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.2d_blocked_rowmajor.js new file mode 100644 index 00000000000..ad1df3a8434 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.2d_blocked_rowmajor.js @@ -0,0 +1,155 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var sqrt = require( '@stdlib/math/base/special/sqrt' ); +var filledarray = require( '@stdlib/array/filled' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var mskfilter = require( './../lib/2d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} dtype - input and output ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, dtype ) { + var mask; + var x; + var y; + + x = filledarrayBy( len, dtype, discreteUniform( -100, 100 ) ); + mask = filledarrayBy( len, 'uint8', discreteUniform( 0, 1 ) ); + y = filledarray( 0.0, len, dtype ); + x = { + 'dtype': dtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + mask = { + 'dtype': 'uint8', + 'data': mask, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + y = { + 'dtype': dtype, + 'data': y, + 'shape': [ len ], + 'strides': [ 1 ], + 'offset': 0, + 'order': order + }; + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mskfilter( x, mask, y ); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var sh; + var t; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + sh = [ 2, len/2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + len = floor( sqrt( len ) ); + sh = [ len, len ]; + len *= len; + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.2d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.2d_columnmajor.js new file mode 100644 index 00000000000..e525f8caefd --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.2d_columnmajor.js @@ -0,0 +1,155 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var sqrt = require( '@stdlib/math/base/special/sqrt' ); +var filledarray = require( '@stdlib/array/filled' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var mskfilter = require( './../lib/2d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} dtype - input and output ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, dtype ) { + var mask; + var x; + var y; + + x = filledarrayBy( len, dtype, discreteUniform( -100, 100 ) ); + mask = filledarrayBy( len, 'uint8', discreteUniform( 0, 1 ) ); + y = filledarray( 0.0, len, dtype ); + x = { + 'dtype': dtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + mask = { + 'dtype': 'uint8', + 'data': mask, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + y = { + 'dtype': dtype, + 'data': y, + 'shape': [ len ], + 'strides': [ 1 ], + 'offset': 0, + 'order': order + }; + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mskfilter( x, mask, y ); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var sh; + var t; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + sh = [ 2, len/2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + len = floor( sqrt( len ) ); + sh = [ len, len ]; + len *= len; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.2d_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.2d_rowmajor.js new file mode 100644 index 00000000000..b43aa4b02eb --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.2d_rowmajor.js @@ -0,0 +1,155 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var sqrt = require( '@stdlib/math/base/special/sqrt' ); +var filledarray = require( '@stdlib/array/filled' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var mskfilter = require( './../lib/2d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} dtype - input and output ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, dtype ) { + var mask; + var x; + var y; + + x = filledarrayBy( len, dtype, discreteUniform( -100, 100 ) ); + mask = filledarrayBy( len, 'uint8', discreteUniform( 0, 1 ) ); + y = filledarray( 0.0, len, dtype ); + x = { + 'dtype': dtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + mask = { + 'dtype': 'uint8', + 'data': mask, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + y = { + 'dtype': dtype, + 'data': y, + 'shape': [ len ], + 'strides': [ 1 ], + 'offset': 0, + 'order': order + }; + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mskfilter( x, mask, y ); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var sh; + var t; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + sh = [ 2, len/2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + len = floor( sqrt( len ) ); + sh = [ len, len ]; + len *= len; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.2d_rowmajor_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.2d_rowmajor_accessors.js new file mode 100644 index 00000000000..d0158a2b068 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.2d_rowmajor_accessors.js @@ -0,0 +1,185 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var sqrt = require( '@stdlib/math/base/special/sqrt' ); +var filledarray = require( '@stdlib/array/filled' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var mskfilter = require( './../lib/2d_accessors.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Returns an array data buffer element. +* +* @private +* @param {Collection} buf - data buffer +* @param {NonNegativeInteger} idx - element index +* @returns {*} element +*/ +function get( buf, idx ) { + return buf[ idx ]; +} + +/** +* Sets an array data buffer element. +* +* @private +* @param {Collection} buf - data buffer +* @param {NonNegativeInteger} idx - element index +* @param {*} value - value to set +*/ +function set( buf, idx, value ) { + buf[ idx ] = value; +} + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} dtype - input and output ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, dtype ) { + var mask; + var x; + var y; + + x = filledarrayBy( len, dtype, discreteUniform( -100, 100 ) ); + mask = filledarrayBy( len, 'uint8', discreteUniform( 0, 1 ) ); + y = filledarray( 0.0, len, dtype ); + x = { + 'dtype': dtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order, + 'accessorProtocol': true, + 'accessors': [ get, set ] + }; + mask = { + 'dtype': 'uint8', + 'data': mask, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order, + 'accessorProtocol': true, + 'accessors': [ get, set ] + }; + y = { + 'dtype': dtype, + 'data': y, + 'shape': [ len ], + 'strides': [ 1 ], + 'offset': 0, + 'order': order, + 'accessorProtocol': true, + 'accessors': [ get, set ] + }; + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mskfilter( x, mask, y ); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var sh; + var t; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+'::accessors:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + sh = [ 2, len/2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+'::accessors:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + len = floor( sqrt( len ) ); + sh = [ len, len ]; + len *= len; + f = createBenchmark( len, sh, t ); + bench( pkg+'::accessors:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.2d_rowmajor_accessors_complex.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.2d_rowmajor_accessors_complex.js new file mode 100644 index 00000000000..dd221ee5d98 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.2d_rowmajor_accessors_complex.js @@ -0,0 +1,194 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var sqrt = require( '@stdlib/math/base/special/sqrt' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var BooleanArray = require( '@stdlib/array/bool' ); +var filledarray = require( '@stdlib/array/filled' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var mskfilter = require( './../lib/2d_accessors.js' ); + + +// VARIABLES // + +var types = [ 'complex64' ]; +var order = 'row-major'; +var abtype = { + 'complex64': 'float32', + 'complex128': 'float64' +}; + + +// FUNCTIONS // + +/** +* Returns an array data buffer element. +* +* @private +* @param {Collection} buf - data buffer +* @param {NonNegativeInteger} idx - element index +* @returns {*} element +*/ +function get( buf, idx ) { + return buf.get( idx ); +} + +/** +* Sets an array data buffer element. +* +* @private +* @param {Collection} buf - data buffer +* @param {NonNegativeInteger} idx - element index +* @param {*} value - value to set +*/ +function set( buf, idx, value ) { + buf.set( value, idx ); +} + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} dtype - input and output ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, dtype ) { + var xbuf; + var mbuf; + var ybuf; + var mask; + var x; + var y; + + xbuf = filledarrayBy( len*2, abtype[ dtype ], discreteUniform( -100, 100 ) ); + mbuf = filledarrayBy( len, 'uint8', discreteUniform( 0, 1 ) ); + ybuf = filledarray( 0.0, len*2, abtype[ dtype ] ); + x = { + 'dtype': dtype, + 'data': new Complex64Array( xbuf.buffer ), + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order, + 'accessorProtocol': true, + 'accessors': [ get, set ] + }; + mask = { + 'dtype': 'bool', + 'data': new BooleanArray( mbuf.buffer ), + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order, + 'accessorProtocol': true, + 'accessors': [ get, set ] + }; + y = { + 'dtype': dtype, + 'data': new Complex64Array( ybuf.buffer ), + 'shape': [ len ], + 'strides': [ 1 ], + 'offset': 0, + 'order': order, + 'accessorProtocol': true, + 'accessors': [ get, set ] + }; + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mskfilter( x, mask, y ); + if ( isnan( ybuf[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( ybuf[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var sh; + var t; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+'::accessors:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + sh = [ 2, len/2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+'::accessors:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + len = floor( sqrt( len ) ); + sh = [ len, len ]; + len *= len; + f = createBenchmark( len, sh, t ); + bench( pkg+'::accessors:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.3d_blocked_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.3d_blocked_columnmajor.js new file mode 100644 index 00000000000..83d183a14db --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.3d_blocked_columnmajor.js @@ -0,0 +1,155 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var cbrt = require( '@stdlib/math/base/special/cbrt' ); +var filledarray = require( '@stdlib/array/filled' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var mskfilter = require( './../lib/3d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} dtype - input and output ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, dtype ) { + var mask; + var x; + var y; + + x = filledarrayBy( len, dtype, discreteUniform( -100, 100 ) ); + mask = filledarrayBy( len, 'uint8', discreteUniform( 0, 1 ) ); + y = filledarray( 0.0, len, dtype ); + x = { + 'dtype': dtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + mask = { + 'dtype': 'uint8', + 'data': mask, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + y = { + 'dtype': dtype, + 'data': y, + 'shape': [ len ], + 'strides': [ 1 ], + 'offset': 0, + 'order': order + }; + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mskfilter( x, mask, y ); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var sh; + var t; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + sh = [ 1, 2, len/2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + len = floor( cbrt( len ) ); + sh = [ len, len, len ]; + len *= len * len; + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.3d_blocked_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.3d_blocked_rowmajor.js new file mode 100644 index 00000000000..57fa9830fb0 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.3d_blocked_rowmajor.js @@ -0,0 +1,155 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var cbrt = require( '@stdlib/math/base/special/cbrt' ); +var filledarray = require( '@stdlib/array/filled' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var mskfilter = require( './../lib/3d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} dtype - input and output ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, dtype ) { + var mask; + var x; + var y; + + x = filledarrayBy( len, dtype, discreteUniform( -100, 100 ) ); + mask = filledarrayBy( len, 'uint8', discreteUniform( 0, 1 ) ); + y = filledarray( 0.0, len, dtype ); + x = { + 'dtype': dtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + mask = { + 'dtype': 'uint8', + 'data': mask, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + y = { + 'dtype': dtype, + 'data': y, + 'shape': [ len ], + 'strides': [ 1 ], + 'offset': 0, + 'order': order + }; + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mskfilter( x, mask, y ); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var sh; + var t; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + sh = [ 1, 2, len/2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + len = floor( cbrt( len ) ); + sh = [ len, len, len ]; + len *= len * len; + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.3d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.3d_columnmajor.js new file mode 100644 index 00000000000..e66c0c88b7a --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.3d_columnmajor.js @@ -0,0 +1,155 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var cbrt = require( '@stdlib/math/base/special/cbrt' ); +var filledarray = require( '@stdlib/array/filled' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var mskfilter = require( './../lib/3d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} dtype - input and output ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, dtype ) { + var mask; + var x; + var y; + + x = filledarrayBy( len, dtype, discreteUniform( -100, 100 ) ); + mask = filledarrayBy( len, 'uint8', discreteUniform( 0, 1 ) ); + y = filledarray( 0.0, len, dtype ); + x = { + 'dtype': dtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + mask = { + 'dtype': 'uint8', + 'data': mask, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + y = { + 'dtype': dtype, + 'data': y, + 'shape': [ len ], + 'strides': [ 1 ], + 'offset': 0, + 'order': order + }; + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mskfilter( x, mask, y ); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var sh; + var t; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + sh = [ 1, 2, len/2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + len = floor( cbrt( len ) ); + sh = [ len, len, len ]; + len *= len * len; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.3d_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.3d_rowmajor.js new file mode 100644 index 00000000000..20c7a70ad8d --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.3d_rowmajor.js @@ -0,0 +1,155 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var cbrt = require( '@stdlib/math/base/special/cbrt' ); +var filledarray = require( '@stdlib/array/filled' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var mskfilter = require( './../lib/3d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} dtype - input and output ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, dtype ) { + var mask; + var x; + var y; + + x = filledarrayBy( len, dtype, discreteUniform( -100, 100 ) ); + mask = filledarrayBy( len, 'uint8', discreteUniform( 0, 1 ) ); + y = filledarray( 0.0, len, dtype ); + x = { + 'dtype': dtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + mask = { + 'dtype': 'uint8', + 'data': mask, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + y = { + 'dtype': dtype, + 'data': y, + 'shape': [ len ], + 'strides': [ 1 ], + 'offset': 0, + 'order': order + }; + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mskfilter( x, mask, y ); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var sh; + var t; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + sh = [ 1, 2, len/2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + len = floor( cbrt( len ) ); + sh = [ len, len, len ]; + len *= len * len; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.4d_blocked_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.4d_blocked_columnmajor.js new file mode 100644 index 00000000000..ab45e646ca9 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.4d_blocked_columnmajor.js @@ -0,0 +1,154 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var filledarray = require( '@stdlib/array/filled' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var mskfilter = require( './../lib/4d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} dtype - input and output ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, dtype ) { + var mask; + var x; + var y; + + x = filledarrayBy( len, dtype, discreteUniform( -100, 100 ) ); + mask = filledarrayBy( len, 'uint8', discreteUniform( 0, 1 ) ); + y = filledarray( 0.0, len, dtype ); + x = { + 'dtype': dtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + mask = { + 'dtype': 'uint8', + 'data': mask, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + y = { + 'dtype': dtype, + 'data': y, + 'shape': [ len ], + 'strides': [ 1 ], + 'offset': 0, + 'order': order + }; + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mskfilter( x, mask, y ); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var sh; + var t; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + sh = [ 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + len = floor( pow( len, 1.0/4.0 ) ); + sh = [ len, len, len, len ]; + len *= len * len * len; + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.4d_blocked_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.4d_blocked_rowmajor.js new file mode 100644 index 00000000000..8582129282c --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.4d_blocked_rowmajor.js @@ -0,0 +1,154 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var filledarray = require( '@stdlib/array/filled' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var mskfilter = require( './../lib/4d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} dtype - input and output ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, dtype ) { + var mask; + var x; + var y; + + x = filledarrayBy( len, dtype, discreteUniform( -100, 100 ) ); + mask = filledarrayBy( len, 'uint8', discreteUniform( 0, 1 ) ); + y = filledarray( 0.0, len, dtype ); + x = { + 'dtype': dtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + mask = { + 'dtype': 'uint8', + 'data': mask, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + y = { + 'dtype': dtype, + 'data': y, + 'shape': [ len ], + 'strides': [ 1 ], + 'offset': 0, + 'order': order + }; + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mskfilter( x, mask, y ); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var sh; + var t; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + sh = [ 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + len = floor( pow( len, 1.0/4.0 ) ); + sh = [ len, len, len, len ]; + len *= len * len * len; + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.4d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.4d_columnmajor.js new file mode 100644 index 00000000000..839e98ce24f --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.4d_columnmajor.js @@ -0,0 +1,154 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var filledarray = require( '@stdlib/array/filled' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var mskfilter = require( './../lib/4d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} dtype - input and output ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, dtype ) { + var mask; + var x; + var y; + + x = filledarrayBy( len, dtype, discreteUniform( -100, 100 ) ); + mask = filledarrayBy( len, 'uint8', discreteUniform( 0, 1 ) ); + y = filledarray( 0.0, len, dtype ); + x = { + 'dtype': dtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + mask = { + 'dtype': 'uint8', + 'data': mask, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + y = { + 'dtype': dtype, + 'data': y, + 'shape': [ len ], + 'strides': [ 1 ], + 'offset': 0, + 'order': order + }; + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mskfilter( x, mask, y ); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var sh; + var t; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + sh = [ 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + len = floor( pow( len, 1.0/4.0 ) ); + sh = [ len, len, len, len ]; + len *= len * len * len; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.4d_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.4d_rowmajor.js new file mode 100644 index 00000000000..aa819ff1121 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.4d_rowmajor.js @@ -0,0 +1,154 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var filledarray = require( '@stdlib/array/filled' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var mskfilter = require( './../lib/4d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} dtype - input and output ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, dtype ) { + var mask; + var x; + var y; + + x = filledarrayBy( len, dtype, discreteUniform( -100, 100 ) ); + mask = filledarrayBy( len, 'uint8', discreteUniform( 0, 1 ) ); + y = filledarray( 0.0, len, dtype ); + x = { + 'dtype': dtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + mask = { + 'dtype': 'uint8', + 'data': mask, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + y = { + 'dtype': dtype, + 'data': y, + 'shape': [ len ], + 'strides': [ 1 ], + 'offset': 0, + 'order': order + }; + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mskfilter( x, mask, y ); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var sh; + var t; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + sh = [ 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + len = floor( pow( len, 1.0/4.0 ) ); + sh = [ len, len, len, len ]; + len *= len * len * len; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.5d_blocked_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.5d_blocked_columnmajor.js new file mode 100644 index 00000000000..92510c659a5 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.5d_blocked_columnmajor.js @@ -0,0 +1,154 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var filledarray = require( '@stdlib/array/filled' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var mskfilter = require( './../lib/5d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} dtype - input and output ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, dtype ) { + var mask; + var x; + var y; + + x = filledarrayBy( len, dtype, discreteUniform( -100, 100 ) ); + mask = filledarrayBy( len, 'uint8', discreteUniform( 0, 1 ) ); + y = filledarray( 0.0, len, dtype ); + x = { + 'dtype': dtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + mask = { + 'dtype': 'uint8', + 'data': mask, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + y = { + 'dtype': dtype, + 'data': y, + 'shape': [ len ], + 'strides': [ 1 ], + 'offset': 0, + 'order': order + }; + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mskfilter( x, mask, y ); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var sh; + var t; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + sh = [ 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + len = floor( pow( len, 1.0/5.0 ) ); + sh = [ len, len, len, len, len ]; + len *= pow( len, 4 ); + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.5d_blocked_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.5d_blocked_rowmajor.js new file mode 100644 index 00000000000..62e40600853 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.5d_blocked_rowmajor.js @@ -0,0 +1,154 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var filledarray = require( '@stdlib/array/filled' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var mskfilter = require( './../lib/5d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} dtype - input and output ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, dtype ) { + var mask; + var x; + var y; + + x = filledarrayBy( len, dtype, discreteUniform( -100, 100 ) ); + mask = filledarrayBy( len, 'uint8', discreteUniform( 0, 1 ) ); + y = filledarray( 0.0, len, dtype ); + x = { + 'dtype': dtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + mask = { + 'dtype': 'uint8', + 'data': mask, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + y = { + 'dtype': dtype, + 'data': y, + 'shape': [ len ], + 'strides': [ 1 ], + 'offset': 0, + 'order': order + }; + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mskfilter( x, mask, y ); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var sh; + var t; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + sh = [ 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + len = floor( pow( len, 1.0/5.0 ) ); + sh = [ len, len, len, len, len ]; + len *= pow( len, 4 ); + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.5d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.5d_columnmajor.js new file mode 100644 index 00000000000..6c8fbd305b2 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.5d_columnmajor.js @@ -0,0 +1,154 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var filledarray = require( '@stdlib/array/filled' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var mskfilter = require( './../lib/5d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} dtype - input and output ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, dtype ) { + var mask; + var x; + var y; + + x = filledarrayBy( len, dtype, discreteUniform( -100, 100 ) ); + mask = filledarrayBy( len, 'uint8', discreteUniform( 0, 1 ) ); + y = filledarray( 0.0, len, dtype ); + x = { + 'dtype': dtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + mask = { + 'dtype': 'uint8', + 'data': mask, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + y = { + 'dtype': dtype, + 'data': y, + 'shape': [ len ], + 'strides': [ 1 ], + 'offset': 0, + 'order': order + }; + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mskfilter( x, mask, y ); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var sh; + var t; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + sh = [ 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + len = floor( pow( len, 1.0/5.0 ) ); + sh = [ len, len, len, len, len ]; + len *= pow( len, 4 ); + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.5d_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.5d_rowmajor.js new file mode 100644 index 00000000000..2f782a4c67b --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.5d_rowmajor.js @@ -0,0 +1,154 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var filledarray = require( '@stdlib/array/filled' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var mskfilter = require( './../lib/5d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} dtype - input and output ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, dtype ) { + var mask; + var x; + var y; + + x = filledarrayBy( len, dtype, discreteUniform( -100, 100 ) ); + mask = filledarrayBy( len, 'uint8', discreteUniform( 0, 1 ) ); + y = filledarray( 0.0, len, dtype ); + x = { + 'dtype': dtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + mask = { + 'dtype': 'uint8', + 'data': mask, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + y = { + 'dtype': dtype, + 'data': y, + 'shape': [ len ], + 'strides': [ 1 ], + 'offset': 0, + 'order': order + }; + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mskfilter( x, mask, y ); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var sh; + var t; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + sh = [ 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + len = floor( pow( len, 1.0/5.0 ) ); + sh = [ len, len, len, len, len ]; + len *= pow( len, 4 ); + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.6d_blocked_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.6d_blocked_columnmajor.js new file mode 100644 index 00000000000..254296e97c0 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.6d_blocked_columnmajor.js @@ -0,0 +1,154 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var filledarray = require( '@stdlib/array/filled' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var mskfilter = require( './../lib/6d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} dtype - input and output ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, dtype ) { + var mask; + var x; + var y; + + x = filledarrayBy( len, dtype, discreteUniform( -100, 100 ) ); + mask = filledarrayBy( len, 'uint8', discreteUniform( 0, 1 ) ); + y = filledarray( 0.0, len, dtype ); + x = { + 'dtype': dtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + mask = { + 'dtype': 'uint8', + 'data': mask, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + y = { + 'dtype': dtype, + 'data': y, + 'shape': [ len ], + 'strides': [ 1 ], + 'offset': 0, + 'order': order + }; + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mskfilter( x, mask, y ); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var sh; + var t; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1, 1 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + sh = [ 1, 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + len = floor( pow( len, 1.0/6.0 ) ); + sh = [ len, len, len, len, len, len ]; + len *= pow( len, 5 ); + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.6d_blocked_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.6d_blocked_rowmajor.js new file mode 100644 index 00000000000..a2904c7c2c7 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.6d_blocked_rowmajor.js @@ -0,0 +1,154 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var filledarray = require( '@stdlib/array/filled' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var mskfilter = require( './../lib/6d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} dtype - input and output ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, dtype ) { + var mask; + var x; + var y; + + x = filledarrayBy( len, dtype, discreteUniform( -100, 100 ) ); + mask = filledarrayBy( len, 'uint8', discreteUniform( 0, 1 ) ); + y = filledarray( 0.0, len, dtype ); + x = { + 'dtype': dtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + mask = { + 'dtype': 'uint8', + 'data': mask, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + y = { + 'dtype': dtype, + 'data': y, + 'shape': [ len ], + 'strides': [ 1 ], + 'offset': 0, + 'order': order + }; + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mskfilter( x, mask, y ); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var sh; + var t; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1, 1 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + sh = [ 1, 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + len = floor( pow( len, 1.0/6.0 ) ); + sh = [ len, len, len, len, len, len ]; + len *= pow( len, 5 ); + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.6d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.6d_columnmajor.js new file mode 100644 index 00000000000..d91725ff4c9 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.6d_columnmajor.js @@ -0,0 +1,154 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var filledarray = require( '@stdlib/array/filled' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var mskfilter = require( './../lib/6d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} dtype - input and output ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, dtype ) { + var mask; + var x; + var y; + + x = filledarrayBy( len, dtype, discreteUniform( -100, 100 ) ); + mask = filledarrayBy( len, 'uint8', discreteUniform( 0, 1 ) ); + y = filledarray( 0.0, len, dtype ); + x = { + 'dtype': dtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + mask = { + 'dtype': 'uint8', + 'data': mask, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + y = { + 'dtype': dtype, + 'data': y, + 'shape': [ len ], + 'strides': [ 1 ], + 'offset': 0, + 'order': order + }; + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mskfilter( x, mask, y ); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var sh; + var t; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1, 1 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + sh = [ 1, 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + len = floor( pow( len, 1.0/6.0 ) ); + sh = [ len, len, len, len, len, len ]; + len *= pow( len, 5 ); + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.6d_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.6d_rowmajor.js new file mode 100644 index 00000000000..e21edfd4861 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.6d_rowmajor.js @@ -0,0 +1,154 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var filledarray = require( '@stdlib/array/filled' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var mskfilter = require( './../lib/6d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} dtype - input and output ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, dtype ) { + var mask; + var x; + var y; + + x = filledarrayBy( len, dtype, discreteUniform( -100, 100 ) ); + mask = filledarrayBy( len, 'uint8', discreteUniform( 0, 1 ) ); + y = filledarray( 0.0, len, dtype ); + x = { + 'dtype': dtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + mask = { + 'dtype': 'uint8', + 'data': mask, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + y = { + 'dtype': dtype, + 'data': y, + 'shape': [ len ], + 'strides': [ 1 ], + 'offset': 0, + 'order': order + }; + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mskfilter( x, mask, y ); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var sh; + var t; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1, 1 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + sh = [ 1, 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + len = floor( pow( len, 1.0/6.0 ) ); + sh = [ len, len, len, len, len, len ]; + len *= pow( len, 5 ); + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.7d_blocked_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.7d_blocked_columnmajor.js new file mode 100644 index 00000000000..e073fcc4b0b --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.7d_blocked_columnmajor.js @@ -0,0 +1,154 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var filledarray = require( '@stdlib/array/filled' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var mskfilter = require( './../lib/7d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} dtype - input and output ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, dtype ) { + var mask; + var x; + var y; + + x = filledarrayBy( len, dtype, discreteUniform( -100, 100 ) ); + mask = filledarrayBy( len, 'uint8', discreteUniform( 0, 1 ) ); + y = filledarray( 0.0, len, dtype ); + x = { + 'dtype': dtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + mask = { + 'dtype': 'uint8', + 'data': mask, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + y = { + 'dtype': dtype, + 'data': y, + 'shape': [ len ], + 'strides': [ 1 ], + 'offset': 0, + 'order': order + }; + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mskfilter( x, mask, y ); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var sh; + var t; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1, 1, 1 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + sh = [ 1, 1, 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + len = floor( pow( len, 1.0/7.0 ) ); + sh = [ len, len, len, len, len, len, len ]; + len *= pow( len, 6 ); + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.7d_blocked_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.7d_blocked_rowmajor.js new file mode 100644 index 00000000000..be8a2464207 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.7d_blocked_rowmajor.js @@ -0,0 +1,154 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var filledarray = require( '@stdlib/array/filled' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var mskfilter = require( './../lib/7d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} dtype - input and output ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, dtype ) { + var mask; + var x; + var y; + + x = filledarrayBy( len, dtype, discreteUniform( -100, 100 ) ); + mask = filledarrayBy( len, 'uint8', discreteUniform( 0, 1 ) ); + y = filledarray( 0.0, len, dtype ); + x = { + 'dtype': dtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + mask = { + 'dtype': 'uint8', + 'data': mask, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + y = { + 'dtype': dtype, + 'data': y, + 'shape': [ len ], + 'strides': [ 1 ], + 'offset': 0, + 'order': order + }; + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mskfilter( x, mask, y ); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var sh; + var t; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1, 1, 1 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + sh = [ 1, 1, 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + len = floor( pow( len, 1.0/7.0 ) ); + sh = [ len, len, len, len, len, len, len ]; + len *= pow( len, 6 ); + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.7d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.7d_columnmajor.js new file mode 100644 index 00000000000..4586688f86a --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.7d_columnmajor.js @@ -0,0 +1,154 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var filledarray = require( '@stdlib/array/filled' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var mskfilter = require( './../lib/7d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} dtype - input and output ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, dtype ) { + var mask; + var x; + var y; + + x = filledarrayBy( len, dtype, discreteUniform( -100, 100 ) ); + mask = filledarrayBy( len, 'uint8', discreteUniform( 0, 1 ) ); + y = filledarray( 0.0, len, dtype ); + x = { + 'dtype': dtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + mask = { + 'dtype': 'uint8', + 'data': mask, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + y = { + 'dtype': dtype, + 'data': y, + 'shape': [ len ], + 'strides': [ 1 ], + 'offset': 0, + 'order': order + }; + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mskfilter( x, mask, y ); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var sh; + var t; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1, 1, 1 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + sh = [ 1, 1, 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + len = floor( pow( len, 1.0/7.0 ) ); + sh = [ len, len, len, len, len, len, len ]; + len *= pow( len, 6 ); + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.7d_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.7d_rowmajor.js new file mode 100644 index 00000000000..54b040cd923 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.7d_rowmajor.js @@ -0,0 +1,154 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var filledarray = require( '@stdlib/array/filled' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var mskfilter = require( './../lib/7d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} dtype - input and output ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, dtype ) { + var mask; + var x; + var y; + + x = filledarrayBy( len, dtype, discreteUniform( -100, 100 ) ); + mask = filledarrayBy( len, 'uint8', discreteUniform( 0, 1 ) ); + y = filledarray( 0.0, len, dtype ); + x = { + 'dtype': dtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + mask = { + 'dtype': 'uint8', + 'data': mask, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + y = { + 'dtype': dtype, + 'data': y, + 'shape': [ len ], + 'strides': [ 1 ], + 'offset': 0, + 'order': order + }; + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mskfilter( x, mask, y ); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var sh; + var t; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1, 1, 1 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + sh = [ 1, 1, 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + len = floor( pow( len, 1.0/7.0 ) ); + sh = [ len, len, len, len, len, len, len ]; + len *= pow( len, 6 ); + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.8d_blocked_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.8d_blocked_columnmajor.js new file mode 100644 index 00000000000..45c60391e0a --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.8d_blocked_columnmajor.js @@ -0,0 +1,154 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var filledarray = require( '@stdlib/array/filled' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var mskfilter = require( './../lib/8d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} dtype - input and output ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, dtype ) { + var mask; + var x; + var y; + + x = filledarrayBy( len, dtype, discreteUniform( -100, 100 ) ); + mask = filledarrayBy( len, 'uint8', discreteUniform( 0, 1 ) ); + y = filledarray( 0.0, len, dtype ); + x = { + 'dtype': dtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + mask = { + 'dtype': 'uint8', + 'data': mask, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + y = { + 'dtype': dtype, + 'data': y, + 'shape': [ len ], + 'strides': [ 1 ], + 'offset': 0, + 'order': order + }; + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mskfilter( x, mask, y ); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var sh; + var t; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1, 1, 1, 1 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + sh = [ 1, 1, 1, 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + len = floor( pow( len, 1.0/8.0 ) ); + sh = [ len, len, len, len, len, len, len, len ]; + len *= pow( len, 7 ); + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.8d_blocked_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.8d_blocked_rowmajor.js new file mode 100644 index 00000000000..ae801e0b568 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.8d_blocked_rowmajor.js @@ -0,0 +1,154 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var filledarray = require( '@stdlib/array/filled' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var mskfilter = require( './../lib/8d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} dtype - input and output ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, dtype ) { + var mask; + var x; + var y; + + x = filledarrayBy( len, dtype, discreteUniform( -100, 100 ) ); + mask = filledarrayBy( len, 'uint8', discreteUniform( 0, 1 ) ); + y = filledarray( 0.0, len, dtype ); + x = { + 'dtype': dtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + mask = { + 'dtype': 'uint8', + 'data': mask, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + y = { + 'dtype': dtype, + 'data': y, + 'shape': [ len ], + 'strides': [ 1 ], + 'offset': 0, + 'order': order + }; + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mskfilter( x, mask, y ); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var sh; + var t; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1, 1, 1, 1 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + sh = [ 1, 1, 1, 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + len = floor( pow( len, 1.0/8.0 ) ); + sh = [ len, len, len, len, len, len, len, len ]; + len *= pow( len, 7 ); + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.8d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.8d_columnmajor.js new file mode 100644 index 00000000000..404b64eba3b --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.8d_columnmajor.js @@ -0,0 +1,154 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var filledarray = require( '@stdlib/array/filled' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var mskfilter = require( './../lib/8d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} dtype - input and output ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, dtype ) { + var mask; + var x; + var y; + + x = filledarrayBy( len, dtype, discreteUniform( -100, 100 ) ); + mask = filledarrayBy( len, 'uint8', discreteUniform( 0, 1 ) ); + y = filledarray( 0.0, len, dtype ); + x = { + 'dtype': dtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + mask = { + 'dtype': 'uint8', + 'data': mask, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + y = { + 'dtype': dtype, + 'data': y, + 'shape': [ len ], + 'strides': [ 1 ], + 'offset': 0, + 'order': order + }; + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mskfilter( x, mask, y ); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var sh; + var t; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1, 1, 1, 1 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + sh = [ 1, 1, 1, 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + len = floor( pow( len, 1.0/8.0 ) ); + sh = [ len, len, len, len, len, len, len, len ]; + len *= pow( len, 7 ); + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.8d_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.8d_rowmajor.js new file mode 100644 index 00000000000..0929f8abb21 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.8d_rowmajor.js @@ -0,0 +1,154 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var filledarray = require( '@stdlib/array/filled' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var mskfilter = require( './../lib/8d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} dtype - input and output ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, dtype ) { + var mask; + var x; + var y; + + x = filledarrayBy( len, dtype, discreteUniform( -100, 100 ) ); + mask = filledarrayBy( len, 'uint8', discreteUniform( 0, 1 ) ); + y = filledarray( 0.0, len, dtype ); + x = { + 'dtype': dtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + mask = { + 'dtype': 'uint8', + 'data': mask, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + y = { + 'dtype': dtype, + 'data': y, + 'shape': [ len ], + 'strides': [ 1 ], + 'offset': 0, + 'order': order + }; + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mskfilter( x, mask, y ); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var sh; + var t; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1, 1, 1, 1 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + sh = [ 1, 1, 1, 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + len = floor( pow( len, 1.0/8.0 ) ); + sh = [ len, len, len, len, len, len, len, len ]; + len *= pow( len, 7 ); + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.9d_blocked_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.9d_blocked_columnmajor.js new file mode 100644 index 00000000000..dea204ec380 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.9d_blocked_columnmajor.js @@ -0,0 +1,154 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var filledarray = require( '@stdlib/array/filled' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var mskfilter = require( './../lib/9d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} dtype - input and output ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, dtype ) { + var mask; + var x; + var y; + + x = filledarrayBy( len, dtype, discreteUniform( -100, 100 ) ); + mask = filledarrayBy( len, 'uint8', discreteUniform( 0, 1 ) ); + y = filledarray( 0.0, len, dtype ); + x = { + 'dtype': dtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + mask = { + 'dtype': 'uint8', + 'data': mask, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + y = { + 'dtype': dtype, + 'data': y, + 'shape': [ len ], + 'strides': [ 1 ], + 'offset': 0, + 'order': order + }; + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mskfilter( x, mask, y ); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var sh; + var t; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1, 1, 1, 1, 1 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + sh = [ 1, 1, 1, 1, 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + len = floor( pow( len, 1.0/9.0 ) ); + sh = [ len, len, len, len, len, len, len, len, len ]; + len *= pow( len, 8 ); + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.9d_blocked_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.9d_blocked_rowmajor.js new file mode 100644 index 00000000000..887182b5a7e --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.9d_blocked_rowmajor.js @@ -0,0 +1,154 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var filledarray = require( '@stdlib/array/filled' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var mskfilter = require( './../lib/9d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} dtype - input and output ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, dtype ) { + var mask; + var x; + var y; + + x = filledarrayBy( len, dtype, discreteUniform( -100, 100 ) ); + mask = filledarrayBy( len, 'uint8', discreteUniform( 0, 1 ) ); + y = filledarray( 0.0, len, dtype ); + x = { + 'dtype': dtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + mask = { + 'dtype': 'uint8', + 'data': mask, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + y = { + 'dtype': dtype, + 'data': y, + 'shape': [ len ], + 'strides': [ 1 ], + 'offset': 0, + 'order': order + }; + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mskfilter( x, mask, y ); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var sh; + var t; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1, 1, 1, 1, 1 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + sh = [ 1, 1, 1, 1, 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + len = floor( pow( len, 1.0/9.0 ) ); + sh = [ len, len, len, len, len, len, len, len, len ]; + len *= pow( len, 8 ); + f = createBenchmark( len, sh, t ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.9d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.9d_columnmajor.js new file mode 100644 index 00000000000..b9521253d74 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.9d_columnmajor.js @@ -0,0 +1,154 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var filledarray = require( '@stdlib/array/filled' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var mskfilter = require( './../lib/9d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} dtype - input and output ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, dtype ) { + var mask; + var x; + var y; + + x = filledarrayBy( len, dtype, discreteUniform( -100, 100 ) ); + mask = filledarrayBy( len, 'uint8', discreteUniform( 0, 1 ) ); + y = filledarray( 0.0, len, dtype ); + x = { + 'dtype': dtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + mask = { + 'dtype': 'uint8', + 'data': mask, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + y = { + 'dtype': dtype, + 'data': y, + 'shape': [ len ], + 'strides': [ 1 ], + 'offset': 0, + 'order': order + }; + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mskfilter( x, mask, y ); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var sh; + var t; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1, 1, 1, 1, 1 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + sh = [ 1, 1, 1, 1, 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + len = floor( pow( len, 1.0/9.0 ) ); + sh = [ len, len, len, len, len, len, len, len, len ]; + len *= pow( len, 8 ); + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.9d_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.9d_rowmajor.js new file mode 100644 index 00000000000..40ff8ce9f2a --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.9d_rowmajor.js @@ -0,0 +1,154 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var filledarray = require( '@stdlib/array/filled' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var mskfilter = require( './../lib/9d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} dtype - input and output ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, dtype ) { + var mask; + var x; + var y; + + x = filledarrayBy( len, dtype, discreteUniform( -100, 100 ) ); + mask = filledarrayBy( len, 'uint8', discreteUniform( 0, 1 ) ); + y = filledarray( 0.0, len, dtype ); + x = { + 'dtype': dtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + mask = { + 'dtype': 'uint8', + 'data': mask, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + y = { + 'dtype': dtype, + 'data': y, + 'shape': [ len ], + 'strides': [ 1 ], + 'offset': 0, + 'order': order + }; + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mskfilter( x, mask, y ); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var sh; + var t; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1, 1, 1, 1, 1 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + sh = [ 1, 1, 1, 1, 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + + len = floor( pow( len, 1.0/9.0 ) ); + sh = [ len, len, len, len, len, len, len, len, len ]; + len *= pow( len, 8 ); + f = createBenchmark( len, sh, t ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],order='+order+',dtype='+t, f ); + } + } +} + +main(); From e2ac30cf50380f8d48c752cde7dfa63482c603ab Mon Sep 17 00:00:00 2001 From: Jaysukh-409 Date: Wed, 14 Aug 2024 14:40:21 +0530 Subject: [PATCH 23/34] docs: added examples in readme --- .../@stdlib/ndarray/base/mskfilter/README.md | 81 +++++++++++++++++++ .../ndarray/base/mskfilter/examples/index.js | 56 +++++++++++++ 2 files changed, 137 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/examples/index.js diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/README.md b/lib/node_modules/@stdlib/ndarray/base/mskfilter/README.md index ad5aa1c4cdb..7e9eb44806b 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/README.md +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/README.md @@ -41,6 +41,51 @@ var mskfilter = require( '@stdlib/ndarray/base/mskfilter' ); Apply a mask to a provided input ndarray and assign unmasked values to elements in a provided one-dimensional output ndarray. ```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var Uint8Array = require( '@stdlib/array/uint8' ); + +// Define the shape of the input and mask arrays: +var shape = [ 3, 1, 2 ]; + +// Define the array strides: +var sx = [ 2, 2, 1 ]; +var sm = [ 2, 2, 1 ]; +var sy = [ 1 ]; + +// Define the index offsets: +var ox = 1; +var om = 0; + +// Create the input, mask and output ndarray-like objects: +var x = { + 'dtype': 'float64', + 'data': 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 ] ), + 'shape': shape, + 'strides': sx, + 'offset': ox, + 'order': 'row-major' +}; +var mask = { + 'dtype': 'uint8', + 'data': new Uint8Array( [ 1, 0, 1, 0, 1, 0 ] ), + 'shape': shape, + 'strides': sm, + 'offset': om, + 'order': 'row-major' +}; +var out = { + 'dtype': 'float64', + 'data': new Float64Array( 3 ), + 'shape': [ 3 ], + 'strides': sy, + 'offset': 0, + 'order': 'row-major' +}; + +mskfilter( [ x, mask, out ] ); + +console.log( out.data ); +// => [ 2.0, 4.0, 6.0 ] ``` The function accepts the following arguments: @@ -71,6 +116,42 @@ Each provided ndarray should be an object with the following properties: ## Examples ```javascript +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var filledarray = require( '@stdlib/array/filled' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var mskfilter = require( '@stdlib/ndarray/base/mskfilter' ); + +var N = 10; +var shape = [ 5, 2 ]; +var x = { + 'dtype': 'float64', + 'data': filledarrayBy( N, 'float64', discreteUniform( -100, 100 ) ), + 'shape': shape, + 'strides': [ 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var mask = { + 'dtype': 'uint8', + 'data': filledarrayBy( N, 'uint8', discreteUniform( 0, 1 ) ), + 'shape': shape, + 'strides': [ 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var y = { + 'dtype': 'float64', + 'data': filledarray( 0, N, 'float64' ), + 'shape': [ N ], + 'strides': [ 1 ], + 'offset': 0, + 'order': 'row-major' +}; + +mskfilter( [ x, mask, y ] ); +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 ) ); ``` diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/examples/index.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/examples/index.js new file mode 100644 index 00000000000..f0fb0832a83 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/examples/index.js @@ -0,0 +1,56 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var filledarray = require( '@stdlib/array/filled' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var mskfilter = require( './../lib' ); + +var N = 10; +var shape = [ 5, 2 ]; +var x = { + 'dtype': 'float64', + 'data': filledarrayBy( N, 'float64', discreteUniform( -100, 100 ) ), + 'shape': shape, + 'strides': [ 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var mask = { + 'dtype': 'uint8', + 'data': filledarrayBy( N, 'uint8', discreteUniform( 0, 1 ) ), + 'shape': shape, + 'strides': [ 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var y = { + 'dtype': 'float64', + 'data': filledarray( 0, N, 'float64' ), + 'shape': [ N ], + 'strides': [ 1 ], + 'offset': 0, + 'order': 'row-major' +}; + +mskfilter( [ x, mask, y ] ); +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 ) ); From f8926fbea612ff9fab337bfcc81b8fc9e7498a3a Mon Sep 17 00:00:00 2001 From: Athan Date: Wed, 14 Aug 2024 10:18:09 -0700 Subject: [PATCH 24/34] Apply suggestions from code review Signed-off-by: Athan --- lib/node_modules/@stdlib/ndarray/base/mskfilter/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/README.md b/lib/node_modules/@stdlib/ndarray/base/mskfilter/README.md index 7e9eb44806b..f301fe8ff58 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/README.md +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/README.md @@ -36,7 +36,7 @@ limitations under the License. var mskfilter = require( '@stdlib/ndarray/base/mskfilter' ); ``` -#### mskfilter ( arrays ) +#### mskfilter( arrays ) Apply a mask to a provided input ndarray and assign unmasked values to elements in a provided one-dimensional output ndarray. From c193d8bab1ea01e5a8e6760ae83176a4fa7e2085 Mon Sep 17 00:00:00 2001 From: Jaysukh-409 Date: Sat, 17 Aug 2024 03:55:31 +0530 Subject: [PATCH 25/34] test: add tests for 2d ndaray --- .../ndarray/base/mskfilter/examples/index.js | 1 + .../ndarray/base/mskfilter/test/test.2d.js | 1123 +++++++++++++++++ 2 files changed, 1124 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.2d.js diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/examples/index.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/examples/index.js index f0fb0832a83..247b69278b4 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/examples/index.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/examples/index.js @@ -53,4 +53,5 @@ var y = { mskfilter( [ x, mask, y ] ); console.log( ndarray2array( x.data, x.shape, x.strides, x.offset, x.order ) ); +console.log( ndarray2array( mask.data, mask.shape, mask.strides, mask.offset, mask.order ) ); console.log( ndarray2array( y.data, y.shape, y.strides, y.offset, y.order ) ); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.2d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.2d.js new file mode 100644 index 00000000000..65417ea1ef3 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.2d.js @@ -0,0 +1,1123 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); +var isSameFloat64Array = require( '@stdlib/assert/is-same-float64array' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Uint8Array = require( '@stdlib/array/uint8' ); +var BooleanArray = require( '@stdlib/array/bool' ); +var ones = require( '@stdlib/array/ones' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var strides2offset = require( '@stdlib/ndarray/base/strides2offset' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); +var mskfilter = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof mskfilter, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function applies a mask to a provided 2-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, singleton dimensions)', function test( t ) { + var expected; + var mask; + var xbuf; + var mbuf; + var ybuf; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 4, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 2-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, singleton dimensions, accessors)', function test( t ) { + var expected; + var mask; + var xbuf; + var mbuf; + var ybuf; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 4, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new BooleanArray( [ 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 2-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, empty)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 0, 0 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 0.0, 0.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 2-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, contiguous)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 2, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 2-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, contiguous, negative strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 2, 2 ]; + st = [ -2, -1 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 3.0, 1.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 2-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, same sign strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 2, 2 ]; + st = [ 4, 1 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 5.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 2-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, mixed sign strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 2, 2 ]; + st = [ 4, -1 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 5.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 2-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2 ]; + st = [ -4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 2-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2 ]; + st = [ bsize*4, -2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 2-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, contiguous, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 2, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new BooleanArray( [ 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 2-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, contiguous, negative strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 2, 2 ]; + st = [ -2, -1 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 5.0, 6.0, 1.0, 2.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 2-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 2, 2 ]; + st = [ 4, 1 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( 2 ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 9.0, 10.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 2-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 2, 2 ]; + st = [ 4, -1 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( 2 ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 9.0, 10.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 2-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2 ]; + st = [ -4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 2-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2 ]; + st = [ bsize*4, -2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 2-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, singleton dimensions)', function test( t ) { + var expected; + var mask; + var xbuf; + var mbuf; + var ybuf; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 4 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 2-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, singleton dimensions, accessors)', function test( t ) { + var expected; + var mask; + var xbuf; + var mbuf; + var ybuf; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 4 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new BooleanArray( [ 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 2-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, empty)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 0, 0 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 0.0, 0.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 2-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, contiguous)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 2, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 2-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, contiguous, negative strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 2, 2 ]; + st = [ -1, -2 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 3.0, 1.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 2-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, same sign strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 2, 2 ]; + st = [ 1, 4 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 5.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 2-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, mixed sign strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 2, 2 ]; + st = [ 1, -4 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 5.0, 1.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 2-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2 ]; + st = [ 2, -bsize*4 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 2-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2 ]; + st = [ -2, 4 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 2-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, contiguous, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 2, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new BooleanArray( [ 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 2-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, contiguous, negative strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 2, 2 ]; + st = [ -1, -2 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 5.0, 6.0, 1.0, 2.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 2-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 2, 2 ]; + st = [ 1, 4 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( 2 ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 9.0, 10.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 2-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 2, 2 ]; + st = [ 1, -4 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( 2 ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 9.0, 10.0, 1.0, 2.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 2-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2 ]; + st = [ 2, -bsize*4 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 2-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2 ]; + st = [ -2, 4 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); From 3ed9b3d796992fa26de7cda6cc69d06b9f8488bc Mon Sep 17 00:00:00 2001 From: Jaysukh-409 Date: Sat, 17 Aug 2024 04:22:00 +0530 Subject: [PATCH 26/34] docs: add repl and typescript declaration --- .../ndarray/base/mskfilter/docs/repl.txt | 44 ++++++++++ .../base/mskfilter/docs/types/index.d.ts | 83 +++++++++++++++++++ .../ndarray/base/mskfilter/docs/types/test.ts | 81 ++++++++++++++++++ 3 files changed, 208 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/docs/types/test.ts diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/base/mskfilter/docs/repl.txt new file mode 100644 index 00000000000..7aa731eb4a1 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/docs/repl.txt @@ -0,0 +1,44 @@ + +{{alias}}( arrays ) + Applies a mask to a provided input ndarray and assigns unmasked values to + elements in a provided one-dimensional output ndarray. + + A provided "ndarray" should be an `object` with the following properties: + + - dtype: data type. + - data: data buffer. + - shape: dimensions. + - strides: stride lengths. + - offset: index offset. + - order: specifies whether an ndarray is row-major (C-style) or column-major + (Fortran-style). + + Parameters + ---------- + arrays: ArrayLikeObject + Array-like object containing an input, mask and output ndarray. + + Examples + -------- + // Define ndarray data and meta data... + > var xbuf = new {{alias:@stdlib/array/float64}}( [ 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 mbuf = new {{alias:@stdlib/array/uint8}}( [ 1, 0, 1, 0, 1, 0 ] ); + > var ybuf = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 0.0 ] ); + > var shape = [ 3, 1, 2 ]; + > var sx = [ 2, 2, 1 ]; + > var sm = [ 2, 2, 1 ]; + > var sy = [ 1 ]; + > var ox = 1; + > var om = 0; + > var order = 'row-major'; + + // Using an ndarray... + > var x = {{alias:@stdlib/ndarray/ctor}}( 'float64', xbuf, shape, sx, ox, order ); + > var mask = {{alias:@stdlib/ndarray/ctor}}( 'uint8', mbuf, shape, sm, om, order ); + > var y = {{alias:@stdlib/ndarray/ctor}}( 'float64', ybuf, [ 3 ], sy, 0, order ); + > {{alias}}( [ x, mask, y ] ); + > y.data + [ 2.0, 4.0, 6.0 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/docs/types/index.d.ts b/lib/node_modules/@stdlib/ndarray/base/mskfilter/docs/types/index.d.ts new file mode 100644 index 00000000000..c81895fb1bc --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/docs/types/index.d.ts @@ -0,0 +1,83 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/// + +import { ArrayLike } from '@stdlib/types/array'; +import { ndarray } from '@stdlib/types/ndarray'; + +/** +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* @param arrays - array-like object containing input array, mask array and output array +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Uint8Array = require( '@stdlib/array/uint8' ); +* +* // Define the shape of the input and mask arrays: +* var shape = [ 3, 1, 2 ]; +* +* // Define the array strides: +* var sx = [ 2, 2, 1 ]; +* var sm = [ 2, 2, 1 ]; +* var sy = [ 1 ]; +* +* // Define the index offsets: +* var ox = 1; +* var om = 0; +* +* // Create the input, mask and output ndarray-like objects: +* var x = { +* 'dtype': 'float64', +* 'data': 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 ] ), +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* var mask = { +* 'dtype': 'uint8', +* 'data': new Uint8Array( [ 1, 0, 1, 0, 1, 0 ] ), +* 'shape': shape, +* 'strides': sm, +* 'offset': om, +* 'order': 'row-major' +* }; +* var out = { +* 'dtype': 'float64', +* 'data': new Float64Array( 3 ), +* 'shape': [ 3 ], +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major' +* }; +* +* mskfilter( [ x, mask, out ] ); +* +* console.log( out.data ); +* // => [ 2.0, 4.0, 6.0 ] +*/ +declare function mskfilter( arrays: ArrayLike ): void; + + +// EXPORTS // + +export = mskfilter; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/docs/types/test.ts b/lib/node_modules/@stdlib/ndarray/base/mskfilter/docs/types/test.ts new file mode 100644 index 00000000000..1211c2f8563 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/docs/types/test.ts @@ -0,0 +1,81 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/// + +import { ndarray } from '@stdlib/types/ndarray'; +import mskfilter = require( './index' ); + +/** +* Mock function to create an ndarray-like object. +* +* @return ndarray-like object +*/ +function array(): ndarray { + const obj: ndarray = { + 'byteLength': 80, + 'BYTES_PER_ELEMENT': 8, + 'data': new Float64Array( 10 ), + 'dtype': 'float64', + 'flags': { + 'ROW_MAJOR_CONTIGUOUS': true, + 'COLUMN_MAJOR_CONTIGUOUS': false + }, + 'length': 10, + 'ndims': 1, + 'offset': 0, + 'order': 'row-major', + 'shape': [ 10 ], + 'strides': [ 1 ], + 'get': (): number => 0, + 'set': (): ndarray => obj + }; + return obj; +} + + +// TESTS // + +// The function returns `undefined`... +{ + const x = array(); + const arrays = [ x, x, x ]; + + mskfilter( arrays ); // $ExpectType void +} + +// The compiler throws an error if the function is provided a first argument which is not an array-like object containing ndarray-like objects... +{ + mskfilter( 5 ); // $ExpectError + mskfilter( true ); // $ExpectError + mskfilter( false ); // $ExpectError + mskfilter( null ); // $ExpectError + mskfilter( undefined ); // $ExpectError + mskfilter( {} ); // $ExpectError + mskfilter( [ 1 ] ); // $ExpectError + mskfilter( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = array(); + const arrays = [ x ]; + + mskfilter(); // $ExpectError + mskfilter( arrays, 10 ); // $ExpectError +} From 59c2e810e7e29c24633fa0a29e951422750f8fe1 Mon Sep 17 00:00:00 2001 From: Jaysukh-409 Date: Mon, 19 Aug 2024 23:27:19 +0530 Subject: [PATCH 27/34] test: add test for 3d to nd ndarray --- .../ndarray/base/mskfilter/test/test.10d.js | 2436 +++++++++++++++++ .../ndarray/base/mskfilter/test/test.2d.js | 2 +- .../ndarray/base/mskfilter/test/test.3d.js | 1287 +++++++++ .../ndarray/base/mskfilter/test/test.4d.js | 1451 ++++++++++ .../ndarray/base/mskfilter/test/test.5d.js | 1616 +++++++++++ .../ndarray/base/mskfilter/test/test.6d.js | 1780 ++++++++++++ .../ndarray/base/mskfilter/test/test.7d.js | 1944 +++++++++++++ .../ndarray/base/mskfilter/test/test.8d.js | 2108 ++++++++++++++ .../ndarray/base/mskfilter/test/test.9d.js | 2272 +++++++++++++++ .../ndarray/base/mskfilter/test/test.nd.js | 589 ++++ 10 files changed, 15484 insertions(+), 1 deletion(-) create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.10d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.3d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.4d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.5d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.6d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.7d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.8d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.9d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.nd.js diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.10d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.10d.js new file mode 100644 index 00000000000..7973444c421 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.10d.js @@ -0,0 +1,2436 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len, max-lines */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); +var isSameFloat64Array = require( '@stdlib/assert/is-same-float64array' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Uint8Array = require( '@stdlib/array/uint8' ); +var BooleanArray = require( '@stdlib/array/bool' ); +var ones = require( '@stdlib/array/ones' ); +var oneTo = require( '@stdlib/array/one-to' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var strides2offset = require( '@stdlib/ndarray/base/strides2offset' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); +var mskfilter = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof mskfilter, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, singleton dimensions)', function test( t ) { + var expected; + var mask; + var xbuf; + var mbuf; + var ybuf; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, singleton dimensions, accessors)', function test( t ) { + var expected; + var mask; + var xbuf; + var mbuf; + var ybuf; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new BooleanArray( [ 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, empty)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 0.0, 0.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, contiguous)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0, 5.0, 7.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, contiguous, negative strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ -8, -8, -8, -8, -8, -8, -4, -2, -2, -1 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( oneTo( 8, 'float64' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( 4 ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 7.0, 5.0, 3.0, 1.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, same sign strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, 16, 16, 8, 4, 2, 1 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( oneTo( 16, 'float32' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 5.0, 9.0, 13.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, mixed sign strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, 16, 16, -8, -4, -2, 1 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( oneTo( 16, 'float32' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 13.0, 9.0, 5.0, 1.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2, 1, 1, 2, 1, 2, 1, 1, 2 ]; + st = [ 32, 16, 16, -16, 8, 8, -4, 4, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 2, 1, 2, 1, 2, 1, 1, 2 ]; + st = [ bsize*64, 32, 16, -16, 8, 8, -4, 4, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 2, bsize*2, 2, 1, 1, 2, 1, 1, 2 ]; + st = [ bsize*64, bsize*32, 16, -8, 8, 8, -4, 4, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, bsize*2, 2, 1, 2, 1, 1, 2 ]; + st = [ bsize*64, bsize*64, bsize*32, -16, 8, 8, -4, 4, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, 2, bsize*2, 2, 1, 1, 1, 2 ]; + st = [ bsize*32, bsize*32, bsize*32, -bsize*16, 8, 4, -4, 4, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, 1, 2, bsize*2, 2, 1, 1, 2 ]; + st = [ bsize*32, bsize*32, bsize*32, -bsize*32, bsize*16, 8, -4, 4, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 2, bsize*2, 2, 1, 2 ]; + st = [ bsize*64, bsize*64, bsize*32, -bsize*32, bsize*32, bsize*16, -8, 4, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, 2, bsize*2, 2, 2 ]; + st = [ bsize*64, bsize*64, bsize*32, -bsize*32, bsize*32, bsize*32, -bsize*16, 8, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, 1, 1, 2, bsize*2, 2 ]; + st = [ bsize*64, bsize*64, bsize*32, -bsize*32, bsize*16, bsize*16, -bsize*16, bsize*8, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, 1, 1, 1, 2, bsize*2 ]; + st = [ bsize*32, bsize*32, bsize*16, -bsize*16, bsize*8, bsize*8, -bsize*8, bsize*8, bsize*4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, contiguous, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 16, 'float32' ) ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0, 9.0, 10.0, 13.0, 14.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, contiguous, negative strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ -8, -8, -8, -8, -8, -8, -4, -2, -2, -1 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 16, 'float32' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( 4 ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 13.0, 14.0, 9.0, 10.0, 5.0, 6.0, 1.0, 2.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, 16, 16, 8, 4, 2, 1 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 32, 'float32' ) ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( 4 ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 9.0, 10.0, 17.0, 18.0, 25.0, 26.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, -16, 16, -8, -4, -2, 1 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 32, 'float32' ) ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( 4 ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 25.0, 26.0, 17.0, 18.0, 9.0, 10.0, 1.0, 2.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2, 1, 1, 2, 1, 2, 1, 1, 2 ]; + st = [ 32, 16, 16, -16, 8, 8, -4, 4, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 2, 1, 2, 1, 2, 1, 1, 2 ]; + st = [ bsize*64, 32, 16, -16, 8, 8, -4, 4, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 2, bsize*2, 2, 1, 1, 2, 1, 1, 2 ]; + st = [ bsize*64, bsize*32, 16, -8, 8, 8, -4, 4, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, bsize*2, 2, 1, 2, 1, 1, 2 ]; + st = [ bsize*64, bsize*64, bsize*32, -16, 8, 8, -4, 4, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, 2, bsize*2, 2, 1, 1, 1, 2 ]; + st = [ bsize*32, bsize*32, bsize*32, -bsize*16, 8, 4, -4, 4, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, 1, 2, bsize*2, 2, 1, 1, 2 ]; + st = [ bsize*32, bsize*32, bsize*32, -bsize*32, bsize*16, 8, -4, 4, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 2, bsize*2, 2, 1, 2 ]; + st = [ bsize*64, bsize*64, bsize*32, -bsize*32, bsize*32, bsize*16, -8, 4, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, 2, bsize*2, 2, 2 ]; + st = [ bsize*64, bsize*64, bsize*32, -bsize*32, bsize*32, bsize*32, -bsize*16, 8, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, 1, 1, 2, bsize*2, 2 ]; + st = [ bsize*64, bsize*64, bsize*32, -bsize*32, bsize*16, bsize*16, -bsize*16, bsize*8, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, 1, 1, 1, 2, bsize*2 ]; + st = [ bsize*32, bsize*32, bsize*16, -bsize*16, bsize*8, bsize*8, -bsize*8, bsize*8, bsize*4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, singleton dimensions)', function test( t ) { + var expected; + var mask; + var xbuf; + var mbuf; + var ybuf; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, singleton dimensions, accessors)', function test( t ) { + var expected; + var mask; + var xbuf; + var mbuf; + var ybuf; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new BooleanArray( [ 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, empty)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 0.0, 0.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, contiguous)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0, 5.0, 7.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, contiguous, negative strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ -1, -1, -1, -1, -1, -1, -1, -2, -4, -4 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( oneTo( 8, 'float64' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( 4 ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 7.0, 5.0, 3.0, 1.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, same sign strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 1, 1, 1, 1, 1, 1, 1, 4, 8, 8 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( oneTo( 16, 'float32' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 5.0, 9.0, 13.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, mixed sign strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 1, 1, 1, 1, 1, 1, -1, -4, 8, -8 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( oneTo( 16, 'float32' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 13.0, 9.0, 5.0, 1.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2, 1, 1, 2, 1, 2, 1, 1, 2 ]; + st = [ 2, bsize*4, bsize*8, -bsize*8, bsize*8, bsize*16, bsize*16, -bsize*32, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 2, 1, 2, 1, 2, 1, 1, 2 ]; + st = [ 2, 4, bsize*8, bsize*16, bsize*16, bsize*32, bsize*32, bsize*64, bsize*64, bsize*64 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 2, bsize*2, 2, 1, 1, 2, 1, 1, 2 ]; + st = [ 2, 4, 8, bsize*16, bsize*32, bsize*32, bsize*32, bsize*64, bsize*64, bsize*64 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, bsize*2, 2, 1, 2, 1, 1, 2 ]; + st = [ 2, 4, 4, 8, bsize*16, bsize*32, bsize*32, bsize*64, bsize*64, bsize*64 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, 2, bsize*2, 2, 1, 1, 1, 2 ]; + st = [ 2, 4, 4, 4, 8, bsize*16, bsize*32, bsize*32, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, 1, 2, bsize*2, 2, 1, 1, 2 ]; + st = [ 2, 4, 4, 4, 4, 8, bsize*16, bsize*32, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 2, bsize*2, 2, 1, 2 ]; + st = [ 2, 4, 4, 8, 8, 8, 16, bsize*32, bsize*64, bsize*64 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, 1, 2, bsize*2, 2, 1 ]; + st = [ 2, 4, 4, 8, 8, 16, 16, 32, bsize*64, bsize*128 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, 1, 1, 2, bsize*2, 2 ]; + st = [ 2, 4, 4, 8, 8, 16, 16, 16, 32, bsize*64 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, 1, 1, 1, 2, bsize*2 ]; + st = [ 2, 4, 4, 8, 8, 16, -16, 16, 16, 32 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, contiguous, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 16, 'float32' ) ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0, 9.0, 10.0, 13.0, 14.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, contiguous, negative strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2, 1 ]; + st = [ -1, -1, -1, -1, -1, -1, -2, -4, -4, -8 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 16, 'float32' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( 4 ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 13.0, 14.0, 9.0, 10.0, 5.0, 6.0, 1.0, 2.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 1, 1, 1, 1, 1, 1, 1, 4, 8, 8 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 32, 'float32' ) ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( 4 ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 9.0, 10.0, 17.0, 18.0, 25.0, 26.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 1, 1, -1, 1, -1, 1, 1, -4, -8, 8 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 32, 'float32' ) ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( 4 ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 9.0, 10.0, 1.0, 2.0, 25.0, 26.0, 17.0, 18.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2, 1, 1, 2, 1, 2, 1, 1, 2 ]; + st = [ 2, bsize*4, bsize*8, -bsize*8, bsize*8, bsize*16, bsize*16, -bsize*32, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 2, 1, 2, 1, 2, 1, 1, 2 ]; + st = [ 2, 4, bsize*8, bsize*16, bsize*16, bsize*32, bsize*32, bsize*64, bsize*64, bsize*64 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 2, bsize*2, 2, 1, 1, 2, 1, 1, 2 ]; + st = [ 2, 4, 8, bsize*16, bsize*32, bsize*32, bsize*32, bsize*64, bsize*64, bsize*64 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, bsize*2, 2, 1, 2, 1, 1, 2 ]; + st = [ 2, 4, 4, 8, bsize*16, bsize*32, bsize*32, bsize*64, bsize*64, bsize*64 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, 2, bsize*2, 2, 1, 1, 1, 2 ]; + st = [ 2, 4, 4, 4, 8, bsize*16, bsize*32, bsize*32, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, 1, 2, bsize*2, 2, 1, 1, 2 ]; + st = [ 2, 4, 4, 4, 4, 8, bsize*16, bsize*32, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 2, bsize*2, 2, 1, 2 ]; + st = [ 2, 4, 4, 8, 8, 8, 16, bsize*32, bsize*64, bsize*64 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, 1, 2, bsize*2, 2, 1 ]; + st = [ 2, 4, 4, 8, 8, 16, 16, 32, bsize*64, bsize*128 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, 1, 1, 2, bsize*2, 2 ]; + st = [ 2, 4, 4, 8, 8, 16, 16, 16, 32, bsize*64 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, 1, 1, 1, 2, bsize*2 ]; + st = [ 2, 4, 4, 8, 8, 16, -16, 16, 16, 32 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.2d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.2d.js index 65417ea1ef3..c2478474ec3 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.2d.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.2d.js @@ -59,7 +59,7 @@ tape( 'the function applies a mask to a provided 2-dimensional input ndarray and var x; var y; - ord = 'column-major'; + ord = 'row-major'; sh = [ 4, 1 ]; st = shape2strides( sh, ord ); o = strides2offset( sh, st ); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.3d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.3d.js new file mode 100644 index 00000000000..8014ae674b3 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.3d.js @@ -0,0 +1,1287 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len, max-lines */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); +var isSameFloat64Array = require( '@stdlib/assert/is-same-float64array' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Uint8Array = require( '@stdlib/array/uint8' ); +var BooleanArray = require( '@stdlib/array/bool' ); +var ones = require( '@stdlib/array/ones' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var strides2offset = require( '@stdlib/ndarray/base/strides2offset' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); +var mskfilter = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof mskfilter, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function applies a mask to a provided 3-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, singleton dimensions)', function test( t ) { + var expected; + var mask; + var xbuf; + var mbuf; + var ybuf; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 4, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 3-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, singleton dimensions, accessors)', function test( t ) { + var expected; + var mask; + var xbuf; + var mbuf; + var ybuf; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 4, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new BooleanArray( [ 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 3-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, empty)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 0, 0, 0 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 0.0, 0.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 3-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, contiguous)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 3-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, contiguous, negative strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 2, 2, 2 ]; + st = [ -4, -2, -1 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 7.0, 5.0, 3.0, 1.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 3-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, same sign strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 2, 1, 2 ]; + st = [ 3, 2, 1 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 5.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 3-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, mixed sign strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 2, 1, 2 ]; + st = [ -3, -2, 1 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 5.0, 1.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 3-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2 ]; + st = [ -4, -4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 3-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 1, bsize*2, 2 ]; + st = [ -bsize*8, -4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 3-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 1, 2, bsize*2 ]; + st = [ bsize*8, bsize*4, -2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 3-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, contiguous, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new BooleanArray( [ 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 3-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, contiguous, negative strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 2, 2, 2 ]; + st = [ -4, -2, -1 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 13.0, 14.0, 9.0, 10.0, 5.0, 6.0, 1.0, 2.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 3-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 2, 1, 2 ]; + st = [ 3, 2, 1 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 9.0, 10.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 3-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 2, 1, 2 ]; + st = [ -3, -2, 1 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( 2 ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 9.0, 10.0, 1.0, 2.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 3-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2 ]; + st = [ -4, -4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 3-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 1, bsize*2, 2 ]; + st = [ -bsize*8, -4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 3-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 1, 2, bsize*2 ]; + st = [ bsize*8, bsize*4, -2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 3-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, singleton dimensions)', function test( t ) { + var expected; + var mask; + var xbuf; + var mbuf; + var ybuf; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 4 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 3-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, singleton dimensions, accessors)', function test( t ) { + var expected; + var mask; + var xbuf; + var mbuf; + var ybuf; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 4 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new BooleanArray( [ 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 3-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, empty)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 0, 0, 0 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 0.0, 0.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 3-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, contiguous)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 3-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, contiguous, negative strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 2, 2, 2 ]; + st = [ -1, -2, -4 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 7.0, 5.0, 3.0, 1.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 3-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, same sign strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 2, 1, 2 ]; + st = [ 1, 2, 3 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 5.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 3-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, mixed sign strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 2, 1, 2 ]; + st = [ -1, -2, 3 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 5.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 3-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2 ]; + st = [ 2, -4, -4 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 3-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1 ]; + st = [ 2, -4, -bsize*8 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 3-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2 ]; + st = [ -2, bsize*4, bsize*4 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 3-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, contiguous, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new BooleanArray( [ 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 3-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, contiguous, negative strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 2, 2, 2 ]; + st = [ -1, -2, -4 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 13.0, 14.0, 9.0, 10.0, 5.0, 6.0, 1.0, 2.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 3-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 2, 1, 2 ]; + st = [ 1, 2, 3 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 9.0, 10.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 3-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 2, 1, 2 ]; + st = [ -1, -2, 3 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( 2 ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 9.0, 10.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 3-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2, 1 ]; + st = [ 2, -bsize*4, -bsize*8 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 3-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1 ]; + st = [ -2, 4, bsize*8 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 3-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2 ]; + st = [ 2, -4, 4 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.4d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.4d.js new file mode 100644 index 00000000000..7c9255a1889 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.4d.js @@ -0,0 +1,1451 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len, max-lines */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); +var isSameFloat64Array = require( '@stdlib/assert/is-same-float64array' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Uint8Array = require( '@stdlib/array/uint8' ); +var BooleanArray = require( '@stdlib/array/bool' ); +var ones = require( '@stdlib/array/ones' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var strides2offset = require( '@stdlib/ndarray/base/strides2offset' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); +var mskfilter = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof mskfilter, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function applies a mask to a provided 4-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, singleton dimensions)', function test( t ) { + var expected; + var mask; + var xbuf; + var mbuf; + var ybuf; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 4, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 4-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, singleton dimensions, accessors)', function test( t ) { + var expected; + var mask; + var xbuf; + var mbuf; + var ybuf; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 4, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new BooleanArray( [ 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 4-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, empty)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 0, 0, 0, 0 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 0.0, 0.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 4-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, contiguous)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 4-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, contiguous, negative strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 2, 2, 1, 2 ]; + st = [ -4, -2, -2, -1 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 7.0, 5.0, 3.0, 1.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 4-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, same sign strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 2, 1, 2, 1 ]; + st = [ 4, 2, 1, 1 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 5.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 4-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, mixed sign strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 2, 1, 2, 1 ]; + st = [ 4, -2, -1, 1 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 5.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 4-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1 ]; + st = [ -4, -4, 2, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 4-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 1, bsize*2, 2, 1 ]; + st = [ -bsize*8, -4, 2, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 4-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 1, 2, bsize*2, 1 ]; + st = [ bsize*8, bsize*4, -2, -2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 4-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 1, 2, 1, bsize*2 ]; + st = [ bsize*8, bsize*4, bsize*4, -2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 4-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, contiguous, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new BooleanArray( [ 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 4-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, contiguous, negative strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 2, 2, 1, 2 ]; + st = [ -4, -2, -2, -1 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 13.0, 14.0, 9.0, 10.0, 5.0, 6.0, 1.0, 2.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 4-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 2, 1, 2, 1 ]; + st = [ 4, 2, 1, 1 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 9.0, 10.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 4-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 2, 1, 2, 1 ]; + st = [ 4, -2, -1, 1 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( 2 ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 9.0, 10.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 4-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1 ]; + st = [ -4, -4, 2, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 4-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 1, bsize*2, 2, 1 ]; + st = [ -bsize*8, -4, 2, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 4-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1 ]; + st = [ -bsize*4, bsize*4, -2, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 4-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*2 ]; + st = [ -bsize*4, bsize*4, -bsize*4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 4-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, singleton dimensions)', function test( t ) { + var expected; + var mask; + var xbuf; + var mbuf; + var ybuf; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 1, 4 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 4-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, singleton dimensions, accessors)', function test( t ) { + var expected; + var mask; + var xbuf; + var mbuf; + var ybuf; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 1, 4 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new BooleanArray( [ 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 4-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, empty)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 0, 0, 0, 0 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 0.0, 0.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 4-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, contiguous)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 4-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, contiguous, negative strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 2, 2, 1, 2 ]; + st = [ -4, -2, -2, -1 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 7.0, 5.0, 3.0, 1.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 4-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, same sign strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 2, 1, 2, 1 ]; + st = [ 1, 2, 4, 8 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 5.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 4-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, mixed sign strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 2, 1, 2, 1 ]; + st = [ 1, -2, -4, 8 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 5.0, 1.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 4-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 1, 2, 1, bsize*2 ]; + st = [ 2, 2, -4, -4 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 4-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 1, 2, bsize*2, 1 ]; + st = [ 2, 2, -4, -bsize*4 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 4-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 1, bsize*2, 1, 2 ]; + st = [ 2, 2, -bsize*4, -bsize*4 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 4-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 1, 2 ]; + st = [ 2, -bsize*4, bsize*4, -bsize*4 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 4-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, contiguous, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new BooleanArray( [ 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 4-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, contiguous, negative strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 2, 2, 1, 2 ]; + st = [ -1, -2, -4, -4 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 13.0, 14.0, 9.0, 10.0, 5.0, 6.0, 1.0, 2.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 4-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 2, 1, 2, 1 ]; + st = [ 1, 2, 4, 8 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 9.0, 10.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 4-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 2, 1, 2, 1 ]; + st = [ 1, 2, -4, -8 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( 2 ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 9.0, 10.0, 1.0, 2.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 4-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1 ]; + st = [ 2, -bsize*4, -bsize*4, -bsize*8 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 4-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1 ]; + st = [ 1, 2, -bsize*4, -bsize*4 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 4-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1 ]; + st = [ 2, 4, -4, -bsize*4 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 4-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*4 ]; + st = [ 2, 4, -4, -4 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.5d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.5d.js new file mode 100644 index 00000000000..ddf17f7e5ae --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.5d.js @@ -0,0 +1,1616 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len, max-lines */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); +var isSameFloat64Array = require( '@stdlib/assert/is-same-float64array' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Uint8Array = require( '@stdlib/array/uint8' ); +var BooleanArray = require( '@stdlib/array/bool' ); +var ones = require( '@stdlib/array/ones' ); +var oneTo = require( '@stdlib/array/one-to' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var strides2offset = require( '@stdlib/ndarray/base/strides2offset' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); +var mskfilter = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof mskfilter, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, singleton dimensions)', function test( t ) { + var expected; + var mask; + var xbuf; + var mbuf; + var ybuf; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 4, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, singleton dimensions, accessors)', function test( t ) { + var expected; + var mask; + var xbuf; + var mbuf; + var ybuf; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 4, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new BooleanArray( [ 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, empty)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 0, 0, 0, 0, 0 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 0.0, 0.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, contiguous)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0, 5.0, 7.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, contiguous, negative strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 2, 2, 1, 2, 2 ]; + st = [ -8, -4, -4, -2, -1 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( oneTo( 16, 'float64' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( 8 ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 8 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 15.0, 13.0, 11.0, 9.0, 7.0, 5.0, 3.0, 1.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, same sign strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = [ 8, 4, 2, 2, 1 ]; + o = strides2offset( sh, st ); + + 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 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 3 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0, 9.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, mixed sign strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = [ 8, 4, -2, -2, 1 ]; + o = strides2offset( sh, st ); + + 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 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 3 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 3.0, 1.0, 11.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 2 ]; + st = [ 8, -8, -4, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1, 2 ]; + st = [ bsize*8, -4, 4, -4, -2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 2 ]; + st = [ bsize*8, bsize*8, -4, -4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, bsize*2, 1 ]; + st = [ bsize*8, -bsize*8, -bsize*4, -2, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2 ]; + st = [ bsize*8, -bsize*8, -bsize*4, -bsize*4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, contiguous, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 16, 'float32' ) ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0, 9.0, 10.0, 13.0, 14.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, contiguous, negative strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = [ -4, -4, -2, -2, -1 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 16, 'float32' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 13.0, 14.0, 9.0, 10.0, 5.0, 6.0, 1.0, 2.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = [ 8, 4, 2, 2, 1 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 24, 'float32' ) ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( 4 ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0, 17.0, 18.0, 21.0, 22.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = [ 8, 4, -2, -2, -1 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 24, 'float32' ) ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( 4 ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 5.0, 6.0, 1.0, 2.0, 21.0, 22.0, 17.0, 18.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 2 ]; + st = [ 8, -8, -4, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1, 2 ]; + st = [ bsize*8, -4, 4, -4, -2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 2 ]; + st = [ bsize*8, bsize*8, -4, -4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*2, 2 ]; + st = [ bsize*8, -bsize*8, -bsize*8, -4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2 ]; + st = [ bsize*8, -bsize*8, -bsize*4, -bsize*4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, singleton dimensions)', function test( t ) { + var expected; + var mask; + var xbuf; + var mbuf; + var ybuf; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 4, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, singleton dimensions, accessors)', function test( t ) { + var expected; + var mask; + var xbuf; + var mbuf; + var ybuf; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 4 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new BooleanArray( [ 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, empty)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 0, 0, 0, 0, 0 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 0.0, 0.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, contiguous)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0, 5.0, 7.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, contiguous, negative strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 2, 2, 1, 2, 2 ]; + st = [ -1, -2, -4, -4, -8 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( oneTo( 16, 'float64' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( 8 ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 8 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 15.0, 13.0, 11.0, 9.0, 7.0, 5.0, 3.0, 1.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, same sign strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = [ 1, 2, 2, 4, 8 ]; + o = strides2offset( sh, st ); + + 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 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 3 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0, 9.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, mixed sign strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = [ 1, 2, -2, -4, 8 ]; + o = strides2offset( sh, st ); + + 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 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 3 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 3.0, 1.0, 11.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 2 ]; + st = [ -2, bsize*4, -bsize*4, bsize*8, bsize*8 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1, 2 ]; + st = [ -2, 4, -bsize*8, bsize*8, bsize*8 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 2 ]; + st = [ -2, 4, -4, bsize*8, bsize*8 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*2, 2 ]; + st = [ -2, 4, -4, 4, bsize*8 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2 ]; + st = [ -2, 4, -4, 8, 8 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, contiguous, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 16, 'float32' ) ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0, 9.0, 10.0, 13.0, 14.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, contiguous, negative strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = [ -1, -2, -2, -4, -4 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 16, 'float32' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 13.0, 14.0, 9.0, 10.0, 5.0, 6.0, 1.0, 2.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = [ 1, 2, 2, 4, 8 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 24, 'float32' ) ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( 4 ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0, 17.0, 18.0, 21.0, 22.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = [ 1, 2, -2, -4, -8 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 24, 'float32' ) ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( 4 ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 21.0, 22.0, 17.0, 18.0, 5.0, 6.0, 1.0, 2.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 2 ]; + st = [ -2, bsize*4, -bsize*4, bsize*8, bsize*8 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 2, 1, 1 ]; + st = [ -2, 4, -bsize*8, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 2 ]; + st = [ -2, 4, -4, bsize*8, bsize*8 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*2, 2 ]; + st = [ -2, -4, -4, 4, bsize*8 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2 ]; + st = [ 2, 4, -4, 8, -8 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.6d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.6d.js new file mode 100644 index 00000000000..8e36109c485 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.6d.js @@ -0,0 +1,1780 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len, max-lines */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); +var isSameFloat64Array = require( '@stdlib/assert/is-same-float64array' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Uint8Array = require( '@stdlib/array/uint8' ); +var BooleanArray = require( '@stdlib/array/bool' ); +var ones = require( '@stdlib/array/ones' ); +var oneTo = require( '@stdlib/array/one-to' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var strides2offset = require( '@stdlib/ndarray/base/strides2offset' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); +var mskfilter = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof mskfilter, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, singleton dimensions)', function test( t ) { + var expected; + var mask; + var xbuf; + var mbuf; + var ybuf; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 4, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, singleton dimensions, accessors)', function test( t ) { + var expected; + var mask; + var xbuf; + var mbuf; + var ybuf; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 4, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new BooleanArray( [ 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, empty)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 0, 0, 0, 0, 0, 0 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 0.0, 0.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, contiguous)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0, 5.0, 7.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, contiguous, negative strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = [ -8, -8, -4, -2, -2, -1 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( oneTo( 8, 'float64' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( 4 ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 7.0, 5.0, 3.0, 1.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, same sign strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 8, 4, 4, 1 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( oneTo( 16, 'float32' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 5.0, 9.0, 13.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, mixed sign strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = [ 16, -16, 8, -4, 4, 1 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( oneTo( 16, 'float32' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 5.0, 1.0, 13.0, 9.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 1, 2 ]; + st = [ 8, -8, -4, 4, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1, 1, 2 ]; + st = [ bsize*8, -4, -4, 4, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 1, 2 ]; + st = [ bsize*8, -bsize*8, -4, 4, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*2, 1, 2 ]; + st = [ bsize*8, -bsize*8, -bsize*8, 4, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, 1, bsize*2, 2 ]; + st = [ bsize*8, -bsize*8, -bsize*8, bsize*8, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, bsize*2 ]; + st = [ bsize*8, -bsize*8, -bsize*4, bsize*4, bsize*4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, contiguous, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 16, 'float32' ) ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0, 9.0, 10.0, 13.0, 14.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, contiguous, negative strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = [ -8, -8, -4, -2, -2, -1 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 16, 'float32' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 13.0, 14.0, 9.0, 10.0, 5.0, 6.0, 1.0, 2.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 8, 4, 4, 1 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 32, 'float32' ) ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( 4 ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 9.0, 10.0, 17.0, 18.0, 25.0, 26.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 8, -4, -4, -1 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 32, 'float32' ) ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( 4 ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 9.0, 10.0, 1.0, 2.0, 25.0, 26.0, 17.0, 18.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 1, 2 ]; + st = [ 8, -8, -4, 4, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1, 1, 2 ]; + st = [ bsize*8, -4, -4, 4, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 1, 2 ]; + st = [ bsize*8, -bsize*8, -4, 4, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*2, 1, 2 ]; + st = [ bsize*8, -bsize*8, -bsize*8, 4, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, 1, bsize*2, 2 ]; + st = [ bsize*8, -bsize*8, -bsize*8, bsize*8, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, bsize*2 ]; + st = [ bsize*8, -bsize*8, -bsize*4, bsize*4, bsize*4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, singleton dimensions)', function test( t ) { + var expected; + var mask; + var xbuf; + var mbuf; + var ybuf; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 4, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, singleton dimensions, accessors)', function test( t ) { + var expected; + var mask; + var xbuf; + var mbuf; + var ybuf; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 4, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new BooleanArray( [ 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, empty)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 0, 0, 0, 0, 0, 0 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 0.0, 0.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, contiguous)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0, 5.0, 7.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, contiguous, negative strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = [ -1, -1, -1, -2, -4, -4 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( oneTo( 8, 'float64' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( 4 ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 7.0, 5.0, 3.0, 1.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, same sign strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = [ 1, 1, 1, 2, 4, 8 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( oneTo( 16, 'float32' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0, 9.0, 11.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, mixed sign strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = [ 1, -1, 1, -2, 4, 8 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( oneTo( 16, 'float32' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 3.0, 1.0, 11.0, 9.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 1, 2, 1, 2 ]; + st = [ 2, bsize*4, bsize*4, -bsize*4, bsize*8, -bsize*8 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1, 1, 2 ]; + st = [ 2, 4, bsize*8, -bsize*8, bsize*8, -bsize*8 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 1, 2 ]; + st = [ 2, 4, 4, -bsize*8, bsize*8, -bsize*8 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*2, 1, 2 ]; + st = [ 2, 4, 4, -4, bsize*8, -bsize*8 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, 2, bsize*2, 1 ]; + st = [ 2, 4, 4, -4, 8, -bsize*16 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, bsize*2 ]; + st = [ 2, 4, 4, -8, 8, -8 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, contiguous, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 16, 'float32' ) ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0, 9.0, 10.0, 13.0, 14.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, contiguous, negative strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = [ -1, -1, -1, -2, -4, -4 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 16, 'float32' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 13.0, 14.0, 9.0, 10.0, 5.0, 6.0, 1.0, 2.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = [ 1, 1, 1, 2, 4, 8 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 32, 'float32' ) ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( 4 ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0, 17.0, 18.0, 21.0, 22.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = [ 1, 1, 1, -2, -4, -8 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 32, 'float32' ) ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( 4 ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 21.0, 22.0, 17.0, 18.0, 5.0, 6.0, 1.0, 2.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 1, 2 ]; + st = [ 2, bsize*4, bsize*4, -bsize*8, bsize*8, -bsize*8 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1, 1, 2 ]; + st = [ 2, 4, bsize*8, -bsize*8, bsize*8, -bsize*8 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 1, 2 ]; + st = [ 2, 4, 4, -bsize*8, bsize*8, -bsize*8 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*2, 1, 2 ]; + st = [ 2, 4, 4, -4, bsize*8, -bsize*8 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, 2, bsize*2, 1 ]; + st = [ 2, 4, 4, -4, 8, -bsize*16 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, bsize*2 ]; + st = [ 2, 4, 4, -8, 8, -8 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.7d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.7d.js new file mode 100644 index 00000000000..1db5abf354b --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.7d.js @@ -0,0 +1,1944 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len, max-lines */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); +var isSameFloat64Array = require( '@stdlib/assert/is-same-float64array' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Uint8Array = require( '@stdlib/array/uint8' ); +var BooleanArray = require( '@stdlib/array/bool' ); +var ones = require( '@stdlib/array/ones' ); +var oneTo = require( '@stdlib/array/one-to' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var strides2offset = require( '@stdlib/ndarray/base/strides2offset' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); +var mskfilter = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof mskfilter, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, singleton dimensions)', function test( t ) { + var expected; + var mask; + var xbuf; + var mbuf; + var ybuf; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, singleton dimensions, accessors)', function test( t ) { + var expected; + var mask; + var xbuf; + var mbuf; + var ybuf; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new BooleanArray( [ 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, empty)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 0, 0, 0, 0, 0, 0, 0 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 0.0, 0.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, contiguous)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0, 5.0, 7.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, contiguous, negative strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2 ]; + st = [ -8, -8, -8, -4, -2, -2, -1 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( oneTo( 8, 'float64' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( 4 ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 7.0, 5.0, 3.0, 1.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, same sign strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 8, 4, 2, 1 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( oneTo( 16, 'float32' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 5.0, 9.0, 13.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, mixed sign strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2 ]; + st = [ -16, 16, -16, 8, -4, 2, 1 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( oneTo( 16, 'float32' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 5.0, 1.0, 13.0, 9.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 2, 1, 2 ]; + st = [ 16, -16, 8, 8, -4, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 2, 1, 1, 2 ]; + st = [ bsize*16, -8, 8, 4, -4, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 2, 1, 2 ]; + st = [ bsize*16, -bsize*16, 8, 8, -4, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, bsize*2, 1, 1, 2 ]; + st = [ bsize*16, -bsize*16, bsize*8, 4, -4, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2, 1, 2 ]; + st = [ bsize*16, -bsize*16, bsize*8, bsize*8, -4, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, bsize*2, 2 ]; + st = [ bsize*16, -bsize*16, bsize*8, bsize*8, -bsize*8, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, 1, bsize*2 ]; + st = [ bsize*16, -bsize*16, bsize*8, bsize*8, -bsize*4, bsize*4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, contiguous, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 16, 'float32' ) ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0, 9.0, 10.0, 13.0, 14.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, contiguous, negative strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 2, 1, 2, 1, 2, 1, 2 ]; + st = [ -8, -8, -4, -4, -2, -2, -1 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 32, 'float32' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( 8 ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 8 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 29.0, 30.0, 25.0, 26.0, 21.0, 22.0, 17.0, 18.0, 13.0, 14.0, 9.0, 10.0, 5.0, 6.0, 1.0, 2.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 8, 4, 2, 1 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 32, 'float32' ) ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( 4 ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 9.0, 10.0, 17.0, 18.0, 25.0, 26.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2 ]; + st = [ -16, 16, -16, -8, 4, -2, 1 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 32, 'float32' ) ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( 4 ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 17.0, 18.0, 25.0, 26.0, 1.0, 2.0, 9.0, 10.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 2, 1, 2 ]; + st = [ 16, -16, 8, 8, -4, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1, 2, 1, 2 ]; + st = [ bsize*16, -8, 8, 8, -4, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 2, 1, 2 ]; + st = [ bsize*16, -bsize*16, 8, 8, -4, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, bsize*2, 1, 1, 2 ]; + st = [ bsize*16, -bsize*16, bsize*8, 4, -4, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2, 1, 2 ]; + st = [ bsize*16, -bsize*16, bsize*8, bsize*8, -4, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, 2, 1, bsize*2, 2 ]; + st = [ bsize*16, -bsize*16, bsize*16, bsize*8, -bsize*8, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, 1, bsize*2 ]; + st = [ bsize*16, -bsize*16, bsize*8, bsize*8, -bsize*4, bsize*4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, singleton dimensions)', function test( t ) { + var expected; + var mask; + var xbuf; + var mbuf; + var ybuf; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, singleton dimensions, accessors)', function test( t ) { + var expected; + var mask; + var xbuf; + var mbuf; + var ybuf; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new BooleanArray( [ 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, empty)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 0, 0, 0, 0, 0, 0, 0 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 0.0, 0.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, contiguous)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0, 5.0, 7.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, contiguous, negative strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2, 1, 2 ]; + st = [ -1, -2, -2, -4, -4, -8, -8 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( oneTo( 16, 'float64' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( 4 ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 15.0, 13.0, 11.0, 9.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, same sign strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 1, 1, 1, 2, 4, 8, 8 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( oneTo( 16, 'float32' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0, 5.0, 7.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, mixed sign strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 1, 1, -1, 2, -4, 8, -8 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( oneTo( 16, 'float32' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 13.0, 15.0, 9.0, 11.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 2, 1, 2 ]; + st = [ 2, -bsize*4, bsize*4, bsize*8, -bsize*8, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 2, 1, 2, 1 ]; + st = [ 2, -4, bsize*8, bsize*8, -bsize*16, bsize*16, bsize*32 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 2, 1, 2 ]; + st = [ 2, -4, -4, bsize*8, bsize*8, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*2, 2, 1, 2 ]; + st = [ 2, -4, -4, 4, bsize*8, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2, 1, 2 ]; + st = [ 2, -4, -4, 8, 8, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, bsize*2, 2 ]; + st = [ 2, -4, -4, 8, 8, 8, bsize*16 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, 1, bsize*2 ]; + st = [ 2, -4, -4, 8, 8, 16, 16 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, contiguous, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 16, 'float32' ) ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0, 9.0, 10.0, 13.0, 14.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, contiguous, negative strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2, 1, 2 ]; + st = [ -1, -2, -2, -4, -4, -8, -8 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 32, 'float32' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( 8 ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 8 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 29.0, 30.0, 25.0, 26.0, 21.0, 22.0, 17.0, 18.0, 13.0, 14.0, 9.0, 10.0, 5.0, 6.0, 1.0, 2.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 1, 1, 1, 2, 4, 8, 8 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 32, 'float32' ) ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( 8 ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 8 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0, 9.0, 10.0, 13.0, 14.0, 17.0, 18.0, 21.0, 22.0, 25.0, 26.0, 29.0, 30.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2 ]; + st = [ -1, 1, -1, -2, 4, -8, 8 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 32, 'float32' ) ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( 8 ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 8 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 5.0, 6.0, 1.0, 2.0, 13.0, 14.0, 9.0, 10.0, 21.0, 22.0, 17.0, 18.0, 29.0, 30.0, 25.0, 26.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 2, 1, 2 ]; + st = [ 2, -bsize*4, -bsize*4, bsize*8, bsize*8, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1, 2, 1, 2 ]; + st = [ 2, -4, -bsize*8, bsize*8, bsize*8, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 2, 1, 2 ]; + st = [ 2, -4, -4, bsize*8, bsize*8, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*2, 1, 2, 2 ]; + st = [ 2, -4, -4, 4, bsize*8, bsize*8, bsize*16 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2, 1, 2 ]; + st = [ 2, -4, -4, 8, 8, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, bsize*2, 2 ]; + st = [ 2, -4, -4, 8, 8, 8, bsize*16 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, 1, bsize*2 ]; + st = [ 2, -4, -4, 8, 8, 16, 16 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.8d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.8d.js new file mode 100644 index 00000000000..ed9706422c9 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.8d.js @@ -0,0 +1,2108 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len, max-lines */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); +var isSameFloat64Array = require( '@stdlib/assert/is-same-float64array' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Uint8Array = require( '@stdlib/array/uint8' ); +var BooleanArray = require( '@stdlib/array/bool' ); +var ones = require( '@stdlib/array/ones' ); +var oneTo = require( '@stdlib/array/one-to' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var strides2offset = require( '@stdlib/ndarray/base/strides2offset' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); +var mskfilter = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof mskfilter, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, singleton dimensions)', function test( t ) { + var expected; + var mask; + var xbuf; + var mbuf; + var ybuf; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, singleton dimensions, accessors)', function test( t ) { + var expected; + var mask; + var xbuf; + var mbuf; + var ybuf; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new BooleanArray( [ 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, empty)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 0.0, 0.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, contiguous)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0, 5.0, 7.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, contiguous, negative strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ -8, -8, -8, -8, -4, -2, -2, -1 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( oneTo( 8, 'float64' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( 4 ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 7.0, 5.0, 3.0, 1.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, same sign strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, 8, 4, 2, 1 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( oneTo( 16, 'float32' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 5.0, 9.0, 13.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, mixed sign strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, -8, -4, -2, 1 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( oneTo( 16, 'float32' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 13.0, 9.0, 5.0, 1.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2, 2, 1, 1, 2, 1, 2 ]; + st = [ 32, -16, 8, -8, -8, 4, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 2, 1, 1, 2, 1, 2 ]; + st = [ -bsize*32, -16, 8, -8, -8, 4, -4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 2, 1, 2, 1, 2 ]; + st = [ -bsize*32, -bsize*32, 16, -8, -8, 4, -4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*2, 2, 2, 1, 2 ]; + st = [ -bsize*32, -bsize*32, bsize*32, -16, -8, 4, -4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2, 2, 1, 2 ]; + st = [ -bsize*32, -bsize*32, bsize*16, -bsize*16, -8, 4, -4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, bsize*2, 2, 2 ]; + st = [ -bsize*32, -bsize*32, bsize*16, -bsize*16, -bsize*16, 8, -4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, bsize*2, 2 ]; + st = [ -bsize*16, -bsize*16, bsize*8, -bsize*8, -bsize*8, bsize*8, -4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 2, 1, bsize*2 ]; + st = [ -bsize*16, -bsize*16, bsize*8, -bsize*8, -bsize*8, bsize*4, -bsize*4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, contiguous, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 16, 'float32' ) ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0, 9.0, 10.0, 13.0, 14.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, contiguous, negative strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ -8, -8, -8, -8, -4, -2, -2, -1 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 16, 'float32' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( 4 ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 13.0, 14.0, 9.0, 10.0, 5.0, 6.0, 1.0, 2.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, 8, 4, 2, 1 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 32, 'float32' ) ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( 4 ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 9.0, 10.0, 17.0, 18.0, 25.0, 26.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, -16, 16, -8, -4, -2, 1 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 32, 'float32' ) ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( 4 ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 25.0, 26.0, 17.0, 18.0, 9.0, 10.0, 1.0, 2.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2, 2, 1, 1, 2, 1, 2 ]; + st = [ 32, 16, 8, -8, -8, 4, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 2, 1, 1, 2, 1, 2 ]; + st = [ -bsize*32, -16, 8, -8, -8, 4, -4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 2, 1, 2, 1, 2 ]; + st = [ -bsize*32, -bsize*32, 16, -8, -8, 4, -4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*2, 2, 2, 1, 2 ]; + st = [ -bsize*32, -bsize*32, bsize*32, -16, -8, 4, -4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2, 2, 1, 2 ]; + st = [ -bsize*32, -bsize*32, bsize*16, -bsize*16, -8, 4, -4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, bsize*2, 2, 2 ]; + st = [ -bsize*32, -bsize*32, bsize*16, -bsize*16, -bsize*16, 8, -4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, bsize*2, 2 ]; + st = [ -bsize*16, -bsize*16, bsize*8, -bsize*8, -bsize*8, bsize*8, -4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 2, 1, bsize*2 ]; + st = [ -bsize*16, -bsize*16, bsize*8, -bsize*8, -bsize*8, bsize*4, -bsize*4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, singleton dimensions)', function test( t ) { + var expected; + var mask; + var xbuf; + var mbuf; + var ybuf; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, singleton dimensions, accessors)', function test( t ) { + var expected; + var mask; + var xbuf; + var mbuf; + var ybuf; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new BooleanArray( [ 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, empty)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 0.0, 0.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, contiguous)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0, 5.0, 7.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, contiguous, negative strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2, 1 ]; + st = [ -1, -1, -1, -1, -2, -4, -4, -8 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( oneTo( 8, 'float64' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( 4 ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 7.0, 5.0, 3.0, 1.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, same sign strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 1, 1, 1, 1, 1, 4, 8, 8 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( oneTo( 16, 'float32' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 5.0, 9.0, 13.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, mixed sign strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 1, 1, 1, 1, -1, -4, 8, -8 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( oneTo( 16, 'float32' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 13.0, 9.0, 5.0, 1.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 1, 2, 1, 2 ]; + st = [ 2, bsize*4, bsize*4, bsize*8, bsize*8, bsize*8, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1, 1, 2, 1, 2 ]; + st = [ 2, -4, bsize*8, bsize*8, bsize*8, bsize*8, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 2, bsize*2, 1, 1, 2, 1, 2 ]; + st = [ 2, 4, 8, bsize*16, bsize*16, bsize*16, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, bsize*2, 1, 2, 1, 2 ]; + st = [ 2, 4, 4, 8, bsize*16, bsize*16, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 2, bsize*2, 1, 1, 2 ]; + st = [ 2, 4, 4, 8, 16, bsize*32, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, bsize*2, 1, 2 ]; + st = [ 2, 4, 4, 8, 8, 16, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 2, bsize*2, 2 ]; + st = [ 2, 4, 4, 8, 8, 8, 16, bsize*32 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 2, 2, bsize*2 ]; + st = [ 2, 4, 4, 8, 8, 8, 16, 32 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, contiguous, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 16, 'float32' ) ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0, 9.0, 10.0, 13.0, 14.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, contiguous, negative strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2, 1 ]; + st = [ -1, -1, -1, -1, -2, -4, -4, -8 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 16, 'float32' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( 4 ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 13.0, 14.0, 9.0, 10.0, 5.0, 6.0, 1.0, 2.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 1, 1, 1, 1, 1, 4, 8, 8 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 32, 'float32' ) ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( 4 ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 9.0, 10.0, 17.0, 18.0, 25.0, 26.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ -1, 1, -1, 1, 1, -4, -8, 8 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 32, 'float32' ) ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( 4 ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 9.0, 10.0, 1.0, 2.0, 25.0, 26.0, 17.0, 18.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 1, 2, 1, 2 ]; + st = [ 2, bsize*4, bsize*4, bsize*8, bsize*8, bsize*8, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1, 1, 2, 1, 2 ]; + st = [ 2, -4, bsize*8, bsize*8, bsize*8, bsize*8, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 2, bsize*2, 1, 1, 2, 1, 2 ]; + st = [ 2, 4, 8, bsize*16, bsize*16, bsize*16, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, bsize*2, 1, 2, 1, 2 ]; + st = [ 2, 4, 4, 8, bsize*16, bsize*16, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 2, bsize*2, 1, 1, 2 ]; + st = [ 2, 4, 4, 8, 16, bsize*32, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, bsize*2, 1, 2 ]; + st = [ 2, 4, 4, 8, 8, 16, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 2, bsize*2, 2 ]; + st = [ 2, 4, 4, 8, 8, 8, 16, bsize*32 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 2, 2, bsize*2 ]; + st = [ 2, 4, 4, 8, 8, 8, 16, 32 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.9d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.9d.js new file mode 100644 index 00000000000..abae2353031 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.9d.js @@ -0,0 +1,2272 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len, max-lines */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); +var isSameFloat64Array = require( '@stdlib/assert/is-same-float64array' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Uint8Array = require( '@stdlib/array/uint8' ); +var BooleanArray = require( '@stdlib/array/bool' ); +var ones = require( '@stdlib/array/ones' ); +var oneTo = require( '@stdlib/array/one-to' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var strides2offset = require( '@stdlib/ndarray/base/strides2offset' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); +var mskfilter = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof mskfilter, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, singleton dimensions)', function test( t ) { + var expected; + var mask; + var xbuf; + var mbuf; + var ybuf; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, singleton dimensions, accessors)', function test( t ) { + var expected; + var mask; + var xbuf; + var mbuf; + var ybuf; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new BooleanArray( [ 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, empty)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 0.0, 0.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, contiguous)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0, 5.0, 7.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, contiguous, negative strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ -8, -8, -8, -8, -8, -4, -2, -2, -1 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( oneTo( 8, 'float64' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( 4 ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 7.0, 5.0, 3.0, 1.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, same sign strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, 16, 8, 4, 2, 1 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( oneTo( 16, 'float32' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 5.0, 9.0, 13.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, mixed sign strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, 16, -8, -4, -2, 1 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( oneTo( 16, 'float32' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 13.0, 9.0, 5.0, 1.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2, 2, 1, 1, 2, 1, 1, 2 ]; + st = [ 32, -16, -8, 8, 8, -4, 4, -4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 2, 1, 1, 2, 1, 1, 2 ]; + st = [ bsize*32, -16, -8, 8, 8, -4, 4, -4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 1, 2, bsize*2, 2, 1, 2, 1, 1, 2 ]; + st = [ bsize*64, -bsize*32, -16, 8, 8, -4, 4, -4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, bsize*2, 2, 2, 1, 1, 2 ]; + st = [ bsize*64, -bsize*64, -bsize*32, 16, 8, -4, 4, -4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 2, bsize*2, 2, 1, 1, 2 ]; + st = [ bsize*64, -bsize*64, -bsize*32, bsize*16, 8, -4, 4, -4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, bsize*2, 2, 1, 2 ]; + st = [ bsize*64, -bsize*64, -bsize*32, bsize*32, bsize*16, -8, 4, -4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 2, bsize*2, 2, 2 ]; + st = [ bsize*64, -bsize*64, -bsize*32, bsize*32, bsize*32, -bsize*16, 8, -4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, 2, bsize*2, 2 ]; + st = [ -bsize*32, -bsize*32, -bsize*16, bsize*16, bsize*16, -bsize*16, bsize*8, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, 1, 1, 2, bsize*2 ]; + st = [ -bsize*32, -bsize*32, -bsize*16, bsize*16, bsize*8, -bsize*8, bsize*8, bsize*4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, contiguous, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 16, 'float32' ) ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0, 9.0, 10.0, 13.0, 14.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, contiguous, negative strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ -8, -8, -8, -8, -8, -4, -2, -2, -1 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 16, 'float32' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( 4 ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 13.0, 14.0, 9.0, 10.0, 5.0, 6.0, 1.0, 2.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, 16, 8, 4, 2, 1 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 32, 'float32' ) ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( 4 ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 9.0, 10.0, 17.0, 18.0, 25.0, 26.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, -16, 16, -8, -4, -2, 1 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 32, 'float32' ) ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( 4 ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 25.0, 26.0, 17.0, 18.0, 9.0, 10.0, 1.0, 2.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2, 2, 1, 1, 2, 1, 1, 2 ]; + st = [ 32, -16, -8, 8, 8, -4, 4, -4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 2, 1, 1, 2, 1, 1, 2 ]; + st = [ bsize*32, -16, -8, 8, 8, -4, 4, -4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 2, bsize*2, 2, 1, 2, 1, 1, 2 ]; + st = [ bsize*64, -bsize*32, -16, 8, 8, -4, 4, -4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, bsize*2, 2, 2, 1, 1, 2 ]; + st = [ bsize*64, -bsize*64, -bsize*32, 16, 8, -4, 4, -4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 2, bsize*2, 2, 1, 1, 2 ]; + st = [ bsize*64, -bsize*64, -bsize*32, bsize*16, 8, -4, 4, -4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, bsize*2, 2, 1, 2 ]; + st = [ bsize*64, -bsize*64, -bsize*32, bsize*32, bsize*16, -8, 4, -4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 2, bsize*2, 2, 2 ]; + st = [ bsize*64, -bsize*64, -bsize*32, bsize*32, bsize*32, -bsize*16, 8, -4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, 2, bsize*2, 2 ]; + st = [ -bsize*32, -bsize*32, -bsize*16, bsize*16, bsize*16, -bsize*16, bsize*8, 4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, 1, 1, 2, bsize*2 ]; + st = [ -bsize*32, -bsize*32, -bsize*16, bsize*16, bsize*8, -bsize*8, bsize*8, bsize*4, 2 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, singleton dimensions)', function test( t ) { + var expected; + var mask; + var xbuf; + var mbuf; + var ybuf; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, singleton dimensions, accessors)', function test( t ) { + var expected; + var mask; + var xbuf; + var mbuf; + var ybuf; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new BooleanArray( [ 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, empty)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 0.0, 0.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, contiguous)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0, 5.0, 7.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, contiguous, negative strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 2, 2, 1, 2, 1, 1, 1, 1, 1 ]; + st = [ -1, -2, -4, -4, -8, -8, -8, -8, -8 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( oneTo( 8, 'float64' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( 4 ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 7.0, 5.0, 3.0, 1.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, same sign strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 1, 1, 1, 1, 1, 1, 4, 8, 8 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( oneTo( 16, 'float32' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 5.0, 9.0, 13.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, mixed sign strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 1, 1, 1, 1, 1, -1, -4, 8, -8 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( oneTo( 16, 'float32' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 13.0, 9.0, 5.0, 1.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2, 2, 1, 1, 2, 1, 1, 2 ]; + st = [ 2, bsize*4, bsize*8, bsize*16, bsize*16, bsize*16, bsize*32, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 2, 1, 1, 1, 1, 1, 2 ]; + st = [ 2, 4, bsize*8, bsize*16, bsize*16, bsize*16, bsize*16, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 2, bsize*2, 2, 1, 1, 1, 1, 2 ]; + st = [ 2, 4, 8, bsize*16, bsize*32, bsize*32, bsize*32, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, bsize*2, 2, 1, 1, 1, 2 ]; + st = [ 2, 4, 4, 8, bsize*16, bsize*32, bsize*32, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, 2, bsize*2, 2, 1, 1, 2 ]; + st = [ 2, 4, 4, 4, 8, bsize*16, bsize*32, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, bsize*2, 2, 1, 2 ]; + st = [ 2, 4, 4, 8, 8, 16, bsize*32, bsize*64, bsize*64 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 2, bsize*2, 2, 2 ]; + st = [ 2, 4, 4, 8, 8, 8, 16, bsize*32, bsize*64 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, 2, bsize*2, 2 ]; + st = [ 2, 4, 4, 8, 8, 8, 8, 16, bsize*32 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, 2, 2, bsize*2 ]; + st = [ 2, 4, 4, 8, 8, 8, 8, 16, 32 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'uint8' ); + ybuf = new Float64Array( len ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, contiguous, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 16, 'float32' ) ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0, 9.0, 10.0, 13.0, 14.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, contiguous, negative strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 2, 2, 1, 2, 1, 1, 1, 1, 1 ]; + st = [ -1, -2, -4, -4, -8, -8, -8, -8, -8 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 16, 'float32' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( 4 ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 13.0, 14.0, 9.0, 10.0, 5.0, 6.0, 1.0, 2.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 1, 1, 1, 1, 1, 1, 4, 8, 8 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 32, 'float32' ) ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( 4 ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 9.0, 10.0, 17.0, 18.0, 25.0, 26.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 1, -1, 1, -1, 1, 1, -4, -8, 8 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 32, 'float32' ) ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( 4 ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 9.0, 10.0, 1.0, 2.0, 25.0, 26.0, 17.0, 18.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2, 2, 1, 1, 2, 1, 1, 2 ]; + st = [ 2, bsize*4, bsize*8, bsize*16, bsize*16, bsize*16, bsize*32, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 2, 1, 1, 1, 1, 1, 2 ]; + st = [ 2, 4, bsize*8, bsize*16, bsize*16, bsize*16, bsize*16, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 2, bsize*2, 2, 1, 1, 1, 1, 2 ]; + st = [ 2, 4, 8, bsize*16, bsize*32, bsize*32, bsize*32, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, bsize*2, 2, 1, 1, 1, 2 ]; + st = [ 2, 4, 4, 8, bsize*16, bsize*32, bsize*32, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, 2, bsize*2, 2, 1, 1, 2 ]; + st = [ 2, 4, 4, 4, 8, bsize*16, bsize*32, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, bsize*2, 2, 1, 2 ]; + st = [ 2, 4, 4, 8, 8, 16, bsize*32, bsize*64, bsize*64 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 2, bsize*2, 2, 2 ]; + st = [ 2, 4, 4, 8, 8, 8, 16, bsize*32, bsize*64 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, 2, bsize*2, 2 ]; + st = [ 2, 4, 4, 8, 8, 8, 8, 16, bsize*32 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var xbuf; + var mbuf; + var ybuf; + var mask; + var len; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var y; + + dt = 'complex64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, 2, 2, bsize*2 ]; + st = [ 2, 4, 4, 8, 8, 8, 8, 16, 32 ]; + o = strides2offset( sh, st ); + len = numel( sh ); + + xbuf = ones( len*2, dt ); + mbuf = ones( len*2, 'bool' ); + ybuf = new Complex64Array( len ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ len ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = ones( len, dt ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.nd.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.nd.js new file mode 100644 index 00000000000..e30f86fdead --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/test/test.nd.js @@ -0,0 +1,589 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); +var isSameFloat64Array = require( '@stdlib/assert/is-same-float64array' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Uint8Array = require( '@stdlib/array/uint8' ); +var BooleanArray = require( '@stdlib/array/bool' ); +var oneTo = require( '@stdlib/array/one-to' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var strides2offset = require( '@stdlib/ndarray/base/strides2offset' ); +var mskfilter = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof mskfilter, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function applies a mask to a provided n-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, singleton dimensions)', function test( t ) { + var expected; + var mask; + var xbuf; + var mbuf; + var ybuf; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided n-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, singleton dimensions, accessors)', function test( t ) { + var expected; + var mask; + var xbuf; + var mbuf; + var ybuf; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new BooleanArray( [ 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided n-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, contiguous)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0, 5.0, 7.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided n-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, same sign strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, 16, 16, 16, 16, 8, 4, 2, 1 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( oneTo( 16, 'float32' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 5.0, 9.0, 13.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided n-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, mixed sign strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, 16, 16, 16, 16, -8, -4, -2, 1 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( oneTo( 16, 'float32' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 13.0, 9.0, 5.0, 1.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided n-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, contiguous, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 16, 'float32' ) ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0, 9.0, 10.0, 13.0, 14.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided n-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, 16, 16, 16, 16, 8, 4, 2, 1 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 32, 'float32' ) ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( 4 ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 9.0, 10.0, 17.0, 18.0, 25.0, 26.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided n-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (row-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, 16, 16, -16, 16, -8, -4, -2, 1 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 32, 'float32' ) ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( 4 ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 25.0, 26.0, 17.0, 18.0, 9.0, 10.0, 1.0, 2.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided n-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, singleton dimensions)', function test( t ) { + var expected; + var mask; + var xbuf; + var mbuf; + var ybuf; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided n-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, singleton dimensions, accessors)', function test( t ) { + var expected; + var mask; + var xbuf; + var mbuf; + var ybuf; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new BooleanArray( [ 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 2 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided n-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, contiguous)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 3.0, 5.0, 7.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided n-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, same sign strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 8, 8 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( oneTo( 16, 'float32' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 1.0, 5.0, 9.0, 13.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided n-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, mixed sign strides)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 1, 1, 1, 1, 1, 1, 1, 1, -1, -4, 8, -8 ]; + o = strides2offset( sh, st ); + + xbuf = new Float64Array( oneTo( 16, 'float32' ) ); + mbuf = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'float64', xbuf, sh, st, o, ord ); + mask = ndarray( 'uint8', mbuf, sh, st, o, ord ); + y = ndarray( 'float64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Float64Array( [ 13.0, 9.0, 5.0, 1.0 ] ); + t.strictEqual( isSameFloat64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided n-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, contiguous, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 16, 'float32' ) ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 5.0, 6.0, 9.0, 10.0, 13.0, 14.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided n-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 8, 8 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 32, 'float32' ) ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( 4 ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 1.0, 2.0, 9.0, 10.0, 17.0, 18.0, 25.0, 26.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a mask to a provided n-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray (column-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var expected; + var xbuf; + var mbuf; + var ybuf; + var mask; + var ord; + var sh; + var st; + var o; + var x; + var y; + + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 1, 1, 1, 1, -1, 1, -1, 1, 1, -4, -8, 8 ]; + o = strides2offset( sh, st ); + + xbuf = new Complex64Array( oneTo( 32, 'float32' ) ); + mbuf = new BooleanArray( [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ] ); + ybuf = new Complex64Array( 4 ); + + x = ndarray( 'complex64', xbuf, sh, st, o, ord ); + mask = ndarray( 'bool', mbuf, sh, st, o, ord ); + y = ndarray( 'complex64', ybuf, [ 4 ], [ 1 ], 0, ord ); + + mskfilter( [ x, mask, y ] ); + + expected = new Complex64Array( [ 9.0, 10.0, 1.0, 2.0, 25.0, 26.0, 17.0, 18.0 ] ); + t.strictEqual( isSameComplex64Array( y.data, expected ), true, 'returns expected value' ); + + t.end(); +}); From 099e7306a3dee4113e10129fa2364473d83c1da9 Mon Sep 17 00:00:00 2001 From: Jaysukh Makvana <111515433+Jaysukh-409@users.noreply.github.com> Date: Tue, 20 Aug 2024 21:48:44 +0530 Subject: [PATCH 28/34] refactor: updated the implementation of mskfilter Signed-off-by: Jaysukh Makvana <111515433+Jaysukh-409@users.noreply.github.com> --- lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js index e416380cbfc..feea149bb55 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js @@ -248,11 +248,6 @@ function mskfilter( arrays ) { throw new Error( 'invalid argument. Output array must have a one-dimensional shape. ndims(y) == %s', y.shape.length ); } - // Verify that the output array and input array have same data type... - if ( x.dtype !== y.dtype ) { - throw new Error( 'invalid arguments. Input and output arrays must have the same data type. dtype(x) == %s. dtype(y) == %s', x.dtype, y.dtype ); - } - // Determine whether we can avoid iteration altogether... if ( ndims === 0 ) { if ( x.accessorProtocol || mask.accessorProtocol || y.accessorProtocol ) { From eaec078da00d33d3c76d2c6a6977f6912d8d2ac3 Mon Sep 17 00:00:00 2001 From: Jaysukh-409 Date: Wed, 21 Aug 2024 18:27:34 +0530 Subject: [PATCH 29/34] refactor: apply suggestions --- .../@stdlib/ndarray/base/mskfilter/README.md | 5 ++++- .../mskfilter/benchmark/benchmark.1d_columnmajor.js | 2 +- .../benchmark.2d_rowmajor_accessors_complex.js | 10 ++++++---- .../@stdlib/ndarray/base/mskfilter/docs/repl.txt | 4 ++-- .../ndarray/base/mskfilter/docs/types/index.d.ts | 6 +++--- .../@stdlib/ndarray/base/mskfilter/lib/10d.js | 4 ++-- .../ndarray/base/mskfilter/lib/10d_accessors.js | 2 +- .../@stdlib/ndarray/base/mskfilter/lib/10d_blocked.js | 4 ++-- .../base/mskfilter/lib/10d_blocked_accessors.js | 2 +- .../@stdlib/ndarray/base/mskfilter/lib/1d.js | 4 ++-- .../@stdlib/ndarray/base/mskfilter/lib/1d_accessors.js | 2 +- .../@stdlib/ndarray/base/mskfilter/lib/2d.js | 8 ++++---- .../@stdlib/ndarray/base/mskfilter/lib/2d_accessors.js | 2 +- .../@stdlib/ndarray/base/mskfilter/lib/2d_blocked.js | 8 ++++---- .../ndarray/base/mskfilter/lib/2d_blocked_accessors.js | 2 +- .../@stdlib/ndarray/base/mskfilter/lib/3d.js | 4 ++-- .../@stdlib/ndarray/base/mskfilter/lib/3d_accessors.js | 2 +- .../@stdlib/ndarray/base/mskfilter/lib/3d_blocked.js | 4 ++-- .../ndarray/base/mskfilter/lib/3d_blocked_accessors.js | 2 +- .../@stdlib/ndarray/base/mskfilter/lib/4d.js | 4 ++-- .../@stdlib/ndarray/base/mskfilter/lib/4d_accessors.js | 2 +- .../@stdlib/ndarray/base/mskfilter/lib/4d_blocked.js | 4 ++-- .../ndarray/base/mskfilter/lib/4d_blocked_accessors.js | 2 +- .../@stdlib/ndarray/base/mskfilter/lib/5d.js | 4 ++-- .../@stdlib/ndarray/base/mskfilter/lib/5d_accessors.js | 2 +- .../@stdlib/ndarray/base/mskfilter/lib/5d_blocked.js | 4 ++-- .../ndarray/base/mskfilter/lib/5d_blocked_accessors.js | 2 +- .../@stdlib/ndarray/base/mskfilter/lib/6d.js | 4 ++-- .../@stdlib/ndarray/base/mskfilter/lib/6d_accessors.js | 2 +- .../@stdlib/ndarray/base/mskfilter/lib/6d_blocked.js | 4 ++-- .../ndarray/base/mskfilter/lib/6d_blocked_accessors.js | 2 +- .../@stdlib/ndarray/base/mskfilter/lib/7d.js | 4 ++-- .../@stdlib/ndarray/base/mskfilter/lib/7d_accessors.js | 2 +- .../@stdlib/ndarray/base/mskfilter/lib/7d_blocked.js | 4 ++-- .../ndarray/base/mskfilter/lib/7d_blocked_accessors.js | 2 +- .../@stdlib/ndarray/base/mskfilter/lib/8d.js | 4 ++-- .../@stdlib/ndarray/base/mskfilter/lib/8d_accessors.js | 2 +- .../@stdlib/ndarray/base/mskfilter/lib/8d_blocked.js | 4 ++-- .../ndarray/base/mskfilter/lib/8d_blocked_accessors.js | 2 +- .../@stdlib/ndarray/base/mskfilter/lib/9d.js | 4 ++-- .../@stdlib/ndarray/base/mskfilter/lib/9d_accessors.js | 2 +- .../@stdlib/ndarray/base/mskfilter/lib/9d_blocked.js | 4 ++-- .../ndarray/base/mskfilter/lib/9d_blocked_accessors.js | 2 +- 43 files changed, 77 insertions(+), 72 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/README.md b/lib/node_modules/@stdlib/ndarray/base/mskfilter/README.md index f301fe8ff58..1a65817a6d8 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/README.md +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/README.md @@ -59,7 +59,7 @@ var om = 0; // Create the input, mask and output ndarray-like objects: var x = { 'dtype': 'float64', - 'data': 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 ] ), + 'data': new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] ), 'shape': shape, 'strides': sx, 'offset': ox, @@ -115,6 +115,8 @@ Each provided ndarray should be an object with the following properties: ## Examples + + ```javascript var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; var filledarray = require( '@stdlib/array/filled' ); @@ -151,6 +153,7 @@ var y = { mskfilter( [ x, mask, y ] ); console.log( ndarray2array( x.data, x.shape, x.strides, x.offset, x.order ) ); +console.log( ndarray2array( mask.data, mask.shape, mask.strides, mask.offset, mask.order ) ); // eslint-disable max-len console.log( ndarray2array( y.data, y.shape, y.strides, y.offset, y.order ) ); ``` diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.1d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.1d_columnmajor.js index a738ff28490..1f447ea998a 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.1d_columnmajor.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.1d_columnmajor.js @@ -76,7 +76,7 @@ function createBenchmark( len, shape, dtype ) { 'dtype': dtype, 'data': y, 'shape': [ len ], - 'strides': [ 1], + 'strides': [ 1 ], 'offset': 0, 'order': order }; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.2d_rowmajor_accessors_complex.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.2d_rowmajor_accessors_complex.js index dd221ee5d98..f718856f2cf 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.2d_rowmajor_accessors_complex.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/benchmark/benchmark.2d_rowmajor_accessors_complex.js @@ -16,6 +16,8 @@ * limitations under the License. */ +/* eslint-disable max-len */ + 'use strict'; // MODULES // @@ -26,8 +28,8 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); var floor = require( '@stdlib/math/base/special/floor' ); var sqrt = require( '@stdlib/math/base/special/sqrt' ); -var Complex64Array = require( '@stdlib/array/complex64' ); var BooleanArray = require( '@stdlib/array/bool' ); +var ctors = require( '@stdlib/array/typed-complex-ctors' ); var filledarray = require( '@stdlib/array/filled' ); var filledarrayBy = require( '@stdlib/array/filled-by' ); var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); @@ -37,7 +39,7 @@ var mskfilter = require( './../lib/2d_accessors.js' ); // VARIABLES // -var types = [ 'complex64' ]; +var types = [ 'complex64', 'complex128' ]; var order = 'row-major'; var abtype = { 'complex64': 'float32', @@ -93,7 +95,7 @@ function createBenchmark( len, shape, dtype ) { ybuf = filledarray( 0.0, len*2, abtype[ dtype ] ); x = { 'dtype': dtype, - 'data': new Complex64Array( xbuf.buffer ), + 'data': new ( ctors( dtype ) )( xbuf.buffer ), 'shape': shape, 'strides': shape2strides( shape, order ), 'offset': 0, @@ -113,7 +115,7 @@ function createBenchmark( len, shape, dtype ) { }; y = { 'dtype': dtype, - 'data': new Complex64Array( ybuf.buffer ), + 'data': new ( ctors( dtype ) )( ybuf.buffer ), 'shape': [ len ], 'strides': [ 1 ], 'offset': 0, diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/base/mskfilter/docs/repl.txt index 7aa731eb4a1..692ada18115 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/docs/repl.txt +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/docs/repl.txt @@ -16,12 +16,12 @@ Parameters ---------- arrays: ArrayLikeObject - Array-like object containing an input, mask and output ndarray. + Array-like object containing an input, mask, and output ndarray. Examples -------- // Define ndarray data and meta data... - > var xbuf = new {{alias:@stdlib/array/float64}}( [ 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 xbuf = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] ); > var mbuf = new {{alias:@stdlib/array/uint8}}( [ 1, 0, 1, 0, 1, 0 ] ); > var ybuf = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 0.0 ] ); > var shape = [ 3, 1, 2 ]; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/docs/types/index.d.ts b/lib/node_modules/@stdlib/ndarray/base/mskfilter/docs/types/index.d.ts index c81895fb1bc..eb87ac9e717 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/docs/types/index.d.ts @@ -26,7 +26,7 @@ import { ndarray } from '@stdlib/types/ndarray'; /** * Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. * -* @param arrays - array-like object containing input array, mask array and output array +* @param arrays - array-like object containing an input array, a mask array, and an output array * * @example * var Float64Array = require( '@stdlib/array/float64' ); @@ -44,10 +44,10 @@ import { ndarray } from '@stdlib/types/ndarray'; * var ox = 1; * var om = 0; * -* // Create the input, mask and output ndarray-like objects: +* // Create the input, mask, and output ndarray-like objects: * var x = { * 'dtype': 'float64', -* 'data': 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 ] ), +* 'data': new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] ), * 'shape': shape, * 'strides': sx, * 'offset': ox, diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d.js index d89340f85b7..fd3400ed2ab 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d.js @@ -49,7 +49,7 @@ * * var x = { * 'dtype': 'float64', -* 'data': 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 ] ), +* 'data': new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] ), * 'shape': shape, * 'strides': sx, * 'offset': ox, @@ -207,7 +207,7 @@ function mskfilter10d( x, mask, y ) { // eslint-disable-line max-statements im = mask.offset; iy = y.offset; - // Cache references to the input, mask and output ndarray buffers... + // Cache references to the input, mask, and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_accessors.js index 529326a570a..1ba6bc18373 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_accessors.js @@ -240,7 +240,7 @@ function mskfilter10d( x, mask, y ) { // eslint-disable-line max-statements im = mask.offset; iy = y.offset; - // Cache references to the input, mask and output ndarray buffers... + // Cache references to the input, mask, and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_blocked.js index 44d6d50055f..e3b596093ce 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_blocked.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_blocked.js @@ -55,7 +55,7 @@ var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); * * var x = { * 'dtype': 'float64', -* 'data': 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 ] ), +* 'data': new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] ), * 'shape': shape, * 'strides': sx, * 'offset': ox, @@ -182,7 +182,7 @@ function blockedmskfilter10d( x, mask, y ) { // eslint-disable-line max-statemen ox = x.offset; om = mask.offset; - // Cache references to the input, mask and output ndarray buffers... + // Cache references to the input, mask, and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_blocked_accessors.js index 1d4727e5064..73f9f84e627 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/10d_blocked_accessors.js @@ -215,7 +215,7 @@ function blockedmskfilter10d( x, mask, y ) { // eslint-disable-line max-statemen ox = x.offset; om = mask.offset; - // Cache references to the input, mask and output ndarray buffers... + // Cache references to the input, mask, and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d.js index 3e9fe59e25a..5305b068699 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d.js @@ -47,7 +47,7 @@ * * var x = { * 'dtype': 'float64', -* 'data': new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0 ] ), +* 'data': new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ), * 'shape': shape, * 'strides': sx, * 'offset': ox, @@ -101,7 +101,7 @@ function mskfilter1d( x, mask, y ) { im = mask.offset; iy = y.offset; - // Cache references to the input, mask and output ndarray buffers... + // Cache references to the input, mask, and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d_accessors.js index 93aab3237d9..38358a43177 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/1d_accessors.js @@ -125,7 +125,7 @@ function mskfilter1d( x, mask, y ) { im = mask.offset; iy = y.offset; - // Cache references to the input, mask and output ndarray buffers... + // Cache references to the input, mask, and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d.js index 7097bd74568..4117bad2c10 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d.js @@ -42,12 +42,12 @@ * var sy = [ 1 ]; * * // Define the index offset: -* var ox = 0; +* var ox = 1; * var om = 0; * * var x = { * 'dtype': 'float64', -* 'data': new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ), +* 'data': new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ), * 'shape': shape, * 'strides': sx, * 'offset': ox, @@ -75,7 +75,7 @@ * mskfilter2d( x, mask, y ); * * console.log( y.data ); -* // => [ 1.0, 3.0 ] +* // => [ 2.0, 4.0 ] */ function mskfilter2d( x, mask, y ) { var xbuf; @@ -125,7 +125,7 @@ function mskfilter2d( x, mask, y ) { im = mask.offset; iy = y.offset; - // Cache references to the input, mask and output ndarray buffers... + // Cache references to the input, mask, and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_accessors.js index 1c989385654..f1e686450a4 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_accessors.js @@ -149,7 +149,7 @@ function mskfilter2d( x, mask, y ) { im = mask.offset; iy = y.offset; - // Cache references to the input, mask and output ndarray buffers... + // Cache references to the input, mask, and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked.js index 72812cb61e1..3356d50c6ee 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked.js @@ -48,12 +48,12 @@ var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); * var sy = [ 1 ]; * * // Define the index offset: -* var ox = 0; +* var ox = 1; * var om = 0; * * var x = { * 'dtype': 'float64', -* 'data': new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ), +* 'data': new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ), * 'shape': shape, * 'strides': sx, * 'offset': ox, @@ -81,7 +81,7 @@ var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); * blockedmskfilter2d( x, mask, y ); * * console.log( y.data ); -* // => [ 1.0, 3.0 ] +* // => [ 2.0, 4.0 ] */ function blockedmskfilter2d( x, mask, y ) { var bsize; @@ -124,7 +124,7 @@ function blockedmskfilter2d( x, mask, y ) { ox = x.offset; om = mask.offset; - // Cache references to the input, mask and output ndarray buffers... + // Cache references to the input, mask, and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked_accessors.js index c2a6136404f..8dd27eee444 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/2d_blocked_accessors.js @@ -148,7 +148,7 @@ function blockedmskfilter2d( x, mask, y ) { ox = x.offset; om = mask.offset; - // Cache references to the input, mask and output ndarray buffers... + // Cache references to the input, mask, and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d.js index 1e6502cb9da..6b131dfd6b8 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d.js @@ -47,7 +47,7 @@ * * var x = { * 'dtype': 'float64', -* 'data': 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 ] ), +* 'data': new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] ), * 'shape': shape, * 'strides': sx, * 'offset': ox, @@ -135,7 +135,7 @@ function mskfilter3d( x, mask, y ) { im = mask.offset; iy = y.offset; - // Cache references to the input, mask and output ndarray buffers... + // Cache references to the input, mask, and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_accessors.js index e0aed33b32a..c6a0a34ac03 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_accessors.js @@ -168,7 +168,7 @@ function mskfilter3d( x, mask, y ) { im = mask.offset; iy = y.offset; - // Cache references to the input, mask and output ndarray buffers... + // Cache references to the input, mask, and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_blocked.js index fffd15ff0b7..640a8406ec0 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_blocked.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_blocked.js @@ -55,7 +55,7 @@ var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); * * var x = { * 'dtype': 'float64', -* 'data': 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 ] ), +* 'data': new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] ), * 'shape': shape, * 'strides': sx, * 'offset': ox, @@ -133,7 +133,7 @@ function blockedmskfilter3d( x, mask, y ) { ox = x.offset; om = mask.offset; - // Cache references to the input, mask and output ndarray buffers... + // Cache references to the input, mask, and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_blocked_accessors.js index 0ca402f9b84..fb8c5008336 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/3d_blocked_accessors.js @@ -166,7 +166,7 @@ function blockedmskfilter3d( x, mask, y ) { ox = x.offset; om = mask.offset; - // Cache references to the input, mask and output ndarray buffers... + // Cache references to the input, mask, and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d.js index 05769c7164a..212a7e8e712 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d.js @@ -47,7 +47,7 @@ * * var x = { * 'dtype': 'float64', -* 'data': 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 ] ), +* 'data': new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] ), * 'shape': shape, * 'strides': sx, * 'offset': ox, @@ -145,7 +145,7 @@ function mskfilter4d( x, mask, y ) { im = mask.offset; iy = y.offset; - // Cache references to the input, mask and output ndarray buffers... + // Cache references to the input, mask, and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_accessors.js index db622109ff7..1a1d34ec8cb 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_accessors.js @@ -178,7 +178,7 @@ function mskfilter4d( x, mask, y ) { im = mask.offset; iy = y.offset; - // Cache references to the input, mask and output ndarray buffers... + // Cache references to the input, mask, and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_blocked.js index c4c840b9abe..734491a6b43 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_blocked.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_blocked.js @@ -55,7 +55,7 @@ var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); * * var x = { * 'dtype': 'float64', -* 'data': 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 ] ), +* 'data': new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] ), * 'shape': shape, * 'strides': sx, * 'offset': ox, @@ -140,7 +140,7 @@ function blockedmskfilter4d( x, mask, y ) { // eslint-disable-line max-statement ox = x.offset; om = mask.offset; - // Cache references to the input, mask and output ndarray buffers... + // Cache references to the input, mask, and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_blocked_accessors.js index 2dd09653212..f1e2125e15e 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/4d_blocked_accessors.js @@ -173,7 +173,7 @@ function blockedmskfilter4d( x, mask, y ) { // eslint-disable-line max-statement ox = x.offset; om = mask.offset; - // Cache references to the input, mask and output ndarray buffers... + // Cache references to the input, mask, and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d.js index 1890064542c..17d6a13099e 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d.js @@ -49,7 +49,7 @@ * * var x = { * 'dtype': 'float64', -* 'data': 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 ] ), +* 'data': new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] ), * 'shape': shape, * 'strides': sx, * 'offset': ox, @@ -157,7 +157,7 @@ function mskfilter5d( x, mask, y ) { im = mask.offset; iy = y.offset; - // Cache references to the input, mask and output ndarray buffers... + // Cache references to the input, mask, and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_accessors.js index 83c3f90bb48..bfb136acef3 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_accessors.js @@ -190,7 +190,7 @@ function mskfilter5d( x, mask, y ) { im = mask.offset; iy = y.offset; - // Cache references to the input, mask and output ndarray buffers... + // Cache references to the input, mask, and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_blocked.js index 4392986f1e1..871c1500eea 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_blocked.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_blocked.js @@ -55,7 +55,7 @@ var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); * * var x = { * 'dtype': 'float64', -* 'data': 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 ] ), +* 'data': new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] ), * 'shape': shape, * 'strides': sx, * 'offset': ox, @@ -147,7 +147,7 @@ function blockedmskfilter5d( x, mask, y ) { // eslint-disable-line max-statement ox = x.offset; om = mask.offset; - // Cache references to the input, mask and output ndarray buffers... + // Cache references to the input, mask, and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_blocked_accessors.js index 6285f965f50..bfa15744395 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/5d_blocked_accessors.js @@ -180,7 +180,7 @@ function blockedmskfilter5d( x, mask, y ) { // eslint-disable-line max-statement ox = x.offset; om = mask.offset; - // Cache references to the input, mask and output ndarray buffers... + // Cache references to the input, mask, and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d.js index 2073b658e83..c8ce0266000 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d.js @@ -49,7 +49,7 @@ * * var x = { * 'dtype': 'float64', -* 'data': 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 ] ), +* 'data': new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] ), * 'shape': shape, * 'strides': sx, * 'offset': ox, @@ -167,7 +167,7 @@ function mskfilter6d( x, mask, y ) { // eslint-disable-line max-statements im = mask.offset; iy = y.offset; - // Cache references to the input, mask and output ndarray buffers... + // Cache references to the input, mask, and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_accessors.js index 1bebe783b18..4037ddfa3e6 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_accessors.js @@ -200,7 +200,7 @@ function mskfilter6d( x, mask, y ) { // eslint-disable-line max-statements im = mask.offset; iy = y.offset; - // Cache references to the input, mask and output ndarray buffers... + // Cache references to the input, mask, and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_blocked.js index 2f6a97159ac..73d04f5bc3e 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_blocked.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_blocked.js @@ -55,7 +55,7 @@ var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); * * var x = { * 'dtype': 'float64', -* 'data': 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 ] ), +* 'data': new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] ), * 'shape': shape, * 'strides': sx, * 'offset': ox, @@ -154,7 +154,7 @@ function blockedmskfilter6d( x, mask, y ) { // eslint-disable-line max-statement ox = x.offset; om = mask.offset; - // Cache references to the input, mask and output ndarray buffers... + // Cache references to the input, mask, and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_blocked_accessors.js index 5558da34356..fd6c82f6b9c 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/6d_blocked_accessors.js @@ -187,7 +187,7 @@ function blockedmskfilter6d( x, mask, y ) { // eslint-disable-line max-statement ox = x.offset; om = mask.offset; - // Cache references to the input, mask and output ndarray buffers... + // Cache references to the input, mask, and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d.js index b0c33d83a05..430a8826849 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d.js @@ -49,7 +49,7 @@ * * var x = { * 'dtype': 'float64', -* 'data': 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 ] ), +* 'data': new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] ), * 'shape': shape, * 'strides': sx, * 'offset': ox, @@ -177,7 +177,7 @@ function mskfilter7d( x, mask, y ) { // eslint-disable-line max-statements im = mask.offset; iy = y.offset; - // Cache references to the input, mask and output ndarray buffers... + // Cache references to the input, mask, and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_accessors.js index 8392c4f6150..fb5cd4f2fb2 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_accessors.js @@ -210,7 +210,7 @@ function mskfilter7d( x, mask, y ) { // eslint-disable-line max-statements im = mask.offset; iy = y.offset; - // Cache references to the input, mask and output ndarray buffers... + // Cache references to the input, mask, and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_blocked.js index d9a29b5e749..37ed0b20ad0 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_blocked.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_blocked.js @@ -55,7 +55,7 @@ var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); * * var x = { * 'dtype': 'float64', -* 'data': 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 ] ), +* 'data': new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] ), * 'shape': shape, * 'strides': sx, * 'offset': ox, @@ -161,7 +161,7 @@ function blockedmskfilter7d( x, mask, y ) { // eslint-disable-line max-statement ox = x.offset; om = mask.offset; - // Cache references to the input, mask and output ndarray buffers... + // Cache references to the input, mask, and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_blocked_accessors.js index 86062f04b92..50415a080c7 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/7d_blocked_accessors.js @@ -194,7 +194,7 @@ function blockedmskfilter7d( x, mask, y ) { // eslint-disable-line max-statement ox = x.offset; om = mask.offset; - // Cache references to the input, mask and output ndarray buffers... + // Cache references to the input, mask, and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d.js index e6d7cba8e27..88c037ffc27 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d.js @@ -49,7 +49,7 @@ * * var x = { * 'dtype': 'float64', -* 'data': 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 ] ), +* 'data': new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] ), * 'shape': shape, * 'strides': sx, * 'offset': ox, @@ -187,7 +187,7 @@ function mskfilter8d( x, mask, y ) { // eslint-disable-line max-statements im = mask.offset; iy = y.offset; - // Cache references to the input, mask and output ndarray buffers... + // Cache references to the input, mask, and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_accessors.js index 29bac68ee50..af19089d491 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_accessors.js @@ -220,7 +220,7 @@ function mskfilter8d( x, mask, y ) { // eslint-disable-line max-statements im = mask.offset; iy = y.offset; - // Cache references to the input, mask and output ndarray buffers... + // Cache references to the input, mask, and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_blocked.js index 7474bc16450..09c48bc2744 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_blocked.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_blocked.js @@ -55,7 +55,7 @@ var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); * * var x = { * 'dtype': 'float64', -* 'data': 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 ] ), +* 'data': new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] ), * 'shape': shape, * 'strides': sx, * 'offset': ox, @@ -168,7 +168,7 @@ function blockedmskfilter8d( x, mask, y ) { // eslint-disable-line max-statement ox = x.offset; om = mask.offset; - // Cache references to the input, mask and output ndarray buffers... + // Cache references to the input, mask, and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_blocked_accessors.js index b9328ed462f..411b9a58ee2 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/8d_blocked_accessors.js @@ -201,7 +201,7 @@ function blockedmskfilter8d( x, mask, y ) { // eslint-disable-line max-statement ox = x.offset; om = mask.offset; - // Cache references to the input, mask and output ndarray buffers... + // Cache references to the input, mask, and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d.js index 1bbe0f1f477..804ad205411 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d.js @@ -49,7 +49,7 @@ * * var x = { * 'dtype': 'float64', -* 'data': 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 ] ), +* 'data': new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] ), * 'shape': shape, * 'strides': sx, * 'offset': ox, @@ -197,7 +197,7 @@ function mskfilter9d( x, mask, y ) { // eslint-disable-line max-statements im = mask.offset; iy = y.offset; - // Cache references to the input, mask and output ndarray buffers... + // Cache references to the input, mask, and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_accessors.js index d89af4eac8f..ab1d3f487ce 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_accessors.js @@ -230,7 +230,7 @@ function mskfilter9d( x, mask, y ) { // eslint-disable-line max-statements im = mask.offset; iy = y.offset; - // Cache references to the input, mask and output ndarray buffers... + // Cache references to the input, mask, and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_blocked.js index d8c73453b90..499a49b4209 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_blocked.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_blocked.js @@ -55,7 +55,7 @@ var blockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' ); * * var x = { * 'dtype': 'float64', -* 'data': 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 ] ), +* 'data': new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] ), * 'shape': shape, * 'strides': sx, * 'offset': ox, @@ -175,7 +175,7 @@ function blockedmskfilter9d( x, mask, y ) { // eslint-disable-line max-statement ox = x.offset; om = mask.offset; - // Cache references to the input, mask and output ndarray buffers... + // Cache references to the input, mask, and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_blocked_accessors.js index 06d8003403e..471eb1d200b 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/9d_blocked_accessors.js @@ -208,7 +208,7 @@ function blockedmskfilter9d( x, mask, y ) { // eslint-disable-line max-statement ox = x.offset; om = mask.offset; - // Cache references to the input, mask and output ndarray buffers... + // Cache references to the input, mask, and output ndarray buffers... xbuf = x.data; mbuf = mask.data; ybuf = y.data; From 1d1acea2b9b2951fe03dae2a279b0958cbb8db1e Mon Sep 17 00:00:00 2001 From: Jaysukh-409 Date: Mon, 16 Sep 2024 16:41:18 +0530 Subject: [PATCH 30/34] feat: update scripts --- .../include/stdlib/ndarray/base/mskfilter.h | 99 + .../stdlib/ndarray/base/mskfilter/dispatch.h | 42 + .../ndarray/base/mskfilter/dispatch_object.h | 94 + .../ndarray/base/mskfilter/internal/permute.h | 29 + .../ndarray/base/mskfilter/internal/range.h | 29 + .../base/mskfilter/internal/sort2ins.h | 29 + .../stdlib/ndarray/base/mskfilter/macros.h | 44 + .../ndarray/base/mskfilter/macros/constants.h | 28 + .../ndarray/base/mskfilter/lib/main.js | 8 +- .../base/mskfilter/scripts/templates/docs.txt | 96 + .../mskfilter/scripts/templates/header.txt | 150 ++ .../mskfilter/scripts/templates/source.txt | 2298 +++++++++++++++++ 12 files changed, 2945 insertions(+), 1 deletion(-) create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/dispatch.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/dispatch_object.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/internal/permute.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/internal/range.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/internal/sort2ins.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/macros.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/macros/constants.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/scripts/templates/docs.txt create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/scripts/templates/header.txt create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/scripts/templates/source.txt diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter.h b/lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter.h new file mode 100644 index 00000000000..6071c3a2c2d --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter.h @@ -0,0 +1,99 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/** +* Header file containing function declarations for ndarray functions which apply a nullary function. +*/ +#ifndef STDLIB_NDARRAY_BASE_MSKFILTER_H +#define STDLIB_NDARRAY_BASE_MSKFILTER_H + +#include "mskfilter/macros.h" +#include "mskfilter/typedefs.h" +#include "mskfilter/dispatch_object.h" +#include "mskfilter/dispatch.h" + +/* +* The following is auto-generated. Do not manually edit. See scripts/loops.js. +*/ + +// BEGIN LOOPS +#include "mskfilter/b_b.h" +#include "mskfilter/b_c.h" +#include "mskfilter/b_d.h" +#include "mskfilter/b_f.h" +#include "mskfilter/b_i.h" +#include "mskfilter/b_k.h" +#include "mskfilter/b_t.h" +#include "mskfilter/b_u.h" +#include "mskfilter/b_z.h" + +#include "mskfilter/c_c.h" +#include "mskfilter/c_z.h" + +#include "mskfilter/d_c.h" +#include "mskfilter/d_d.h" +#include "mskfilter/d_f.h" +#include "mskfilter/d_z.h" + +#include "mskfilter/f_c.h" +#include "mskfilter/f_d.h" +#include "mskfilter/f_f.h" +#include "mskfilter/f_z.h" + +#include "mskfilter/i_d.h" +#include "mskfilter/i_i.h" +#include "mskfilter/i_u.h" +#include "mskfilter/i_z.h" + +#include "mskfilter/k_c.h" +#include "mskfilter/k_d.h" +#include "mskfilter/k_f.h" +#include "mskfilter/k_i.h" +#include "mskfilter/k_k.h" +#include "mskfilter/k_t.h" +#include "mskfilter/k_u.h" +#include "mskfilter/k_z.h" + +#include "mskfilter/s_b.h" +#include "mskfilter/s_c.h" +#include "mskfilter/s_d.h" +#include "mskfilter/s_f.h" +#include "mskfilter/s_i.h" +#include "mskfilter/s_k.h" +#include "mskfilter/s_s.h" +#include "mskfilter/s_t.h" +#include "mskfilter/s_u.h" +#include "mskfilter/s_z.h" + +#include "mskfilter/t_c.h" +#include "mskfilter/t_d.h" +#include "mskfilter/t_f.h" +#include "mskfilter/t_i.h" +#include "mskfilter/t_t.h" +#include "mskfilter/t_u.h" +#include "mskfilter/t_z.h" + +#include "mskfilter/u_d.h" +#include "mskfilter/u_u.h" +#include "mskfilter/u_z.h" + +#include "mskfilter/x_x.h" + +#include "mskfilter/z_c.h" +#include "mskfilter/z_z.h" +// END LOOPS diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/dispatch.h b/lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/dispatch.h new file mode 100644 index 00000000000..4f85be2e2f7 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/dispatch.h @@ -0,0 +1,42 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#ifndef STDLIB_NDARRAY_BASE_MSKFILTER_DISPATCH_H +#define STDLIB_NDARRAY_BASE_MSKFILTER_DISPATCH_H + +#include "stdlib/ndarray/base/mskfilter/dispatch_object.h" +#include "stdlib/ndarray/ctor.h" +#include + +/* +* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. +*/ +#ifdef __cplusplus +extern "C" { +#endif + +/** +* Dispatches to a unary ndarray function according to the dimensionality of provided ndarray arguments. +*/ +int8_t stdlib_ndarray_unary_mskfilter_dispatch( const struct ndarrayUnaryMskfilterDispatchObject *obj, struct ndarray *arrays[] ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_NDARRAY_BASE_MSKFILTER_DISPATCH_H diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/dispatch_object.h b/lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/dispatch_object.h new file mode 100644 index 00000000000..6b233db8f89 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/dispatch_object.h @@ -0,0 +1,94 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#ifndef STDLIB_NDARRAY_BASE_MSKFILTER_DISPATCH_OBJECT_H +#define STDLIB_NDARRAY_BASE_MSKFILTER_DISPATCH_OBJECT_H + +#include "stdlib/ndarray/base/mskfilter/typedefs.h" +#include + +/* +* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. +*/ +#ifdef __cplusplus +extern "C" { +#endif + +/** +* Structure for grouping unary function dispatch information. +* +* @example +* #include "stdlib/ndarray/base/mskfilter/b_b.h" +* #include +* #include +* +* ndarrayUnaryMskfilterFcn functions[] = { +* stdlib_ndarray_mskfilter_b_b_0d, +* stdlib_ndarray_mskfilter_b_b_1d, +* stdlib_ndarray_mskfilter_b_b_2d, +* stdlib_ndarray_mskfilter_b_b_3d, +* stdlib_ndarray_mskfilter_b_b_4d, +* stdlib_ndarray_mskfilter_b_b_5d, +* stdlib_ndarray_mskfilter_b_b_6d, +* stdlib_ndarray_mskfilter_b_b_7d, +* stdlib_ndarray_mskfilter_b_b_8d, +* stdlib_ndarray_mskfilter_b_b_9d, +* stdlib_ndarray_mskfilter_b_b_10d +* stdlib_ndarray_mskfilter_b_b_nd +* }; + +* ndarrayUnaryMskfilterFcn blocked_functions[] = { +* stdlib_ndarray_mskfilter_b_b_2d_blocked, +* stdlib_ndarray_mskfilter_b_b_3d_blocked, +* stdlib_ndarray_mskfilter_b_b_4d_blocked, +* stdlib_ndarray_mskfilter_b_b_5d_blocked, +* stdlib_ndarray_mskfilter_b_b_6d_blocked, +* stdlib_ndarray_mskfilter_b_b_7d_blocked, +* stdlib_ndarray_mskfilter_b_b_8d_blocked, +* stdlib_ndarray_mskfilter_b_b_9d_blocked, +* stdlib_ndarray_mskfilter_b_b_10d_blocked +* }; +* +* ndarrayUnaryMskfilterDispatchObject obj = { +* functions, +* 12, +* blocked_functions +* 9 +* }; +* +* // ... +*/ +struct ndarrayUnaryMskfilterDispatchObject { + // Array containing unary ndarray functions for performing element-wise mask operation: + ndarrayUnaryMskfilterFcn *functions; + + // Number of unary ndarray functions: + int32_t nfunctions; + + // Array containing unary ndarray functions for performing element-wise mask operation using loop blocking: + ndarrayUnaryMskfilterFcn *blocked_functions; + + // Number of blocked unary ndarray functions: + int32_t nblockedfunctions; +}; + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_NDARRAY_BASE_MSKFILTER_DISPATCH_OBJECT_H diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/internal/permute.h b/lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/internal/permute.h new file mode 100644 index 00000000000..b9892b38123 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/internal/permute.h @@ -0,0 +1,29 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#ifndef STDLIB_NDARRAY_BASE_MSKFILTER_INTERNAL_PERMUTE_H +#define STDLIB_NDARRAY_BASE_MSKFILTER_INTERNAL_PERMUTE_H + +#include + +/** +* Permutes an input array according to a provided index array. +*/ +void stdlib_ndarray_base_mskfilter_internal_permute( const int64_t n, const int64_t *arr, const int64_t *idx, int64_t *out ); + +#endif // !STDLIB_NDARRAY_BASE_MSKFILTER_INTERNAL_PERMUTE_H diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/internal/range.h b/lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/internal/range.h new file mode 100644 index 00000000000..c45325fe4ee --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/internal/range.h @@ -0,0 +1,29 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#ifndef STDLIB_NDARRAY_BASE_MSKFILTER_INTERNAL_RANGE_H +#define STDLIB_NDARRAY_BASE_MSKFILTER_INTERNAL_RANGE_H + +#include + +/** +* Writes `n` evenly spaced values from `0` to `n-1` to an output array. +*/ +void stdlib_ndarray_base_mskfilter_internal_range( const int64_t n, int64_t *out ); + +#endif // !STDLIB_NDARRAY_BASE_MSKFILTER_INTERNAL_RANGE_H diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/internal/sort2ins.h b/lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/internal/sort2ins.h new file mode 100644 index 00000000000..b5c685e531a --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/internal/sort2ins.h @@ -0,0 +1,29 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#ifndef STDLIB_NDARRAY_BASE_MSKFILTER_INTERNAL_SORT2INS_H +#define STDLIB_NDARRAY_BASE_MSKFILTER_INTERNAL_SORT2INS_H + +#include + +/** +* Simultaneously sorts two arrays based on the sort order of the first array using insertion sort. +*/ +void stdlib_ndarray_base_mskfilter_internal_sort2ins( const int64_t n, int64_t *x, int64_t *y ); + +#endif // !STDLIB_NDARRAY_BASE_MSKFILTER_INTERNAL_SORT2INS_H diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/macros.h b/lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/macros.h new file mode 100644 index 00000000000..8b40c1beac6 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/macros.h @@ -0,0 +1,44 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#ifndef STDLIB_NDARRAY_BASE_MSKFILTER_MACROS_H +#define STDLIB_NDARRAY_BASE_MSKFILTER_MACROS_H + +#include "stdlib/ndarray/base/mskfilter/macros/constants.h" +#include "stdlib/ndarray/base/mskfilter/macros/1d.h" +#include "stdlib/ndarray/base/mskfilter/macros/2d.h" +#include "stdlib/ndarray/base/mskfilter/macros/2d_blocked.h" +#include "stdlib/ndarray/base/mskfilter/macros/3d.h" +#include "stdlib/ndarray/base/mskfilter/macros/3d_blocked.h" +#include "stdlib/ndarray/base/mskfilter/macros/4d.h" +#include "stdlib/ndarray/base/mskfilter/macros/4d_blocked.h" +#include "stdlib/ndarray/base/mskfilter/macros/5d.h" +#include "stdlib/ndarray/base/mskfilter/macros/5d_blocked.h" +#include "stdlib/ndarray/base/mskfilter/macros/6d.h" +#include "stdlib/ndarray/base/mskfilter/macros/6d_blocked.h" +#include "stdlib/ndarray/base/mskfilter/macros/7d.h" +#include "stdlib/ndarray/base/mskfilter/macros/7d_blocked.h" +#include "stdlib/ndarray/base/mskfilter/macros/8d.h" +#include "stdlib/ndarray/base/mskfilter/macros/8d_blocked.h" +#include "stdlib/ndarray/base/mskfilter/macros/9d.h" +#include "stdlib/ndarray/base/mskfilter/macros/9d_blocked.h" +#include "stdlib/ndarray/base/mskfilter/macros/10d.h" +#include "stdlib/ndarray/base/mskfilter/macros/10d_blocked.h" +#include "stdlib/ndarray/base/mskfilter/macros/nd.h" + +#endif // !STDLIB_NDARRAY_BASE_MSKFILTER_MACROS_H diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/macros/constants.h b/lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/macros/constants.h new file mode 100644 index 00000000000..768ab35cc80 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/macros/constants.h @@ -0,0 +1,28 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#ifndef STDLIB_NDARRAY_BASE_MSKFILTER_MACROS_CONSTANTS_H +#define STDLIB_NDARRAY_BASE_MSKFILTER_MACROS_CONSTANTS_H + +// Define a default block size in units of bytes (Note: 64b is a common cache line size. How applicable the common cache line size is here is debatable, given that, depending on the associated stride(s), the innermost loop may not iterate over adjacent elements. The primary goal is to have a block size in which all data within a block can always fit in (L1) cache, regardless of cache size (i.e., cache-oblivious). For reference, a common L1 cache size is 32kB per core. For best performance, block sizes should be tuned based on system hardware; however, such tuning is not readily available to us here. Without obvious better alternatives, 64b has some theoretical (and practical) underpinning, and it should be good enough for most inputs, especially for ndarrays with near contiguity.): +#define STDLIB_NDARRAY_MSKFILTER_BLOCK_SIZE_IN_BYTES 64 + +// Define a default block size in units of elements (Note: 64 bytes / 8 bytes per element; i.e., default element size is same as a double): +#define STDLIB_NDARRAY_MSKFILTER_BLOCK_SIZE_IN_ELEMENTS 8 + +#endif // !STDLIB_NDARRAY_BASE_MSKFILTER_MACROS_CONSTANTS_H diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js index feea149bb55..20c6f964e36 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/main.js @@ -27,6 +27,8 @@ var ndarray2object = require( '@stdlib/ndarray/base/ndarraylike2object' ); var minmaxViewBufferIndex = require( '@stdlib/ndarray/base/minmax-view-buffer-index' ); var format = require( '@stdlib/string/format' ); var numel = require( '@stdlib/ndarray/base/numel' ); +var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); +var isBooleanArray = require( '@stdlib/assert/is-booleanarray' ); var blockedaccessormskfilter2d = require( './2d_blocked_accessors.js' ); var blockedaccessormskfilter3d = require( './3d_blocked_accessors.js' ); var blockedaccessormskfilter4d = require( './4d_blocked_accessors.js' ); @@ -219,7 +221,11 @@ function mskfilter( arrays ) { // Unpack the ndarrays and standardize ndarray meta data: x = ndarray2object( arrays[ 0 ] ); - mask = ndarray2object( arrays[ 1 ] ); + if ( isBooleanArray( arrays[ 1 ] ) ) { + mask = ndarray2object( reinterpretBoolean( arrays[ 1 ], 0 ) ); + } else { + mask = ndarray2object( arrays[ 1 ] ); + } y = ndarray2object( arrays[ 2 ] ); // Verify that the input and mask arrays have the same number of dimensions... diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/scripts/templates/docs.txt b/lib/node_modules/@stdlib/ndarray/base/mskfilter/scripts/templates/docs.txt new file mode 100644 index 00000000000..912b72ad11c --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/scripts/templates/docs.txt @@ -0,0 +1,96 @@ +#### stdlib_ndarray_mskfilter_{{SIGNATURE}}( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h"{{EXAMPLE_INCLUDES}} +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_{{INPUT_NDARRAY_1_DTYPE_UPPER}}; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_{{OUTPUT_NDARRAY_DTYPE_UPPER}}; + +// Create underlying byte arrays: +uint8_t xbuf[] = { {{INPUT_NDARRAY_1_BYTES_2D}} }; +uint8_t mbuf[] = { {{INPUT_NDARRAY_2_BYTES_2D}} }; +uint8_t ybuf[] = { {{OUTPUT_NDARRAY_BYTES_2D}} }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { {{INPUT_NDARRAY_SHAPE_2D}} }; +int64_t shy[] = { {{INPUT_NDARRAY_SHAPE_2D}} }; +int64_t shm[] = { {{OUTPUT_NDARRAY_SHAPE_2D}} }; + +// Define the strides: +int64_t sx[] = { {{INPUT_NDARRAY_1_STRIDES_2D}} }; +int64_t sm[] = { {{INPUT_NDARRAY_2_STRIDES_2D}} }; +int64_t sy[] = { {{OUTPUT_NDARRAY_STRIDES_2D}} }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, ndims, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_{{SIGNATURE}}( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_{{SIGNATURE}}( struct ndarray *arrays[] ); +``` diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/scripts/templates/header.txt b/lib/node_modules/@stdlib/ndarray/base/mskfilter/scripts/templates/header.txt new file mode 100644 index 00000000000..bf8de119968 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/scripts/templates/header.txt @@ -0,0 +1,150 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) {{YEAR}} {{COPYRIGHT}}. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* +* The following is auto-generated. Do not manually edit. See scripts/loops.js. +*/ + +#ifndef STDLIB_NDARRAY_BASE_MSKFILTER_{{INCLUDE_GUARD}}_H +#define STDLIB_NDARRAY_BASE_MSKFILTER_{{INCLUDE_GUARD}}_H + +#include "stdlib/ndarray/ctor.h" +#include + +/* +* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. +*/ +#ifdef __cplusplus +extern "C" { +#endif + +/** +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +*/ +int8_t stdlib_ndarray_{{SIGNATURE}}( struct ndarray *arrays[] ); + +/** +* Applies a mask to a provided 0-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +*/ +int8_t stdlib_ndarray_{{SIGNATURE}}_0d( struct ndarray *arrays[] ); + +/** +* Applies a mask to a provided 1-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +*/ +int8_t stdlib_ndarray_{{SIGNATURE}}_1d( struct ndarray *arrays[] ); + +/** +* Applies a mask to a provided 2-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +*/ +int8_t stdlib_ndarray_{{SIGNATURE}}_2d( struct ndarray *arrays[] ); + +/** +* Applies a mask to a provided 2-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +*/ +int8_t stdlib_ndarray_{{SIGNATURE}}_2d_blocked( struct ndarray *arrays[] ); + +/** +* Applies a mask to a provided 3-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +*/ +int8_t stdlib_ndarray_{{SIGNATURE}}_3d( struct ndarray *arrays[] ); + +/** +* Applies a mask to a provided 3-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +*/ +int8_t stdlib_ndarray_{{SIGNATURE}}_3d_blocked( struct ndarray *arrays[] ); + +/** +* Applies a mask to a provided 4-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +*/ +int8_t stdlib_ndarray_{{SIGNATURE}}_4d( struct ndarray *arrays[] ); + +/** +* Applies a mask to a provided 4-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +*/ +int8_t stdlib_ndarray_{{SIGNATURE}}_4d_blocked( struct ndarray *arrays[] ); + +/** +* Applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +*/ +int8_t stdlib_ndarray_{{SIGNATURE}}_5d( struct ndarray *arrays[] ); + +/** +* Applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +*/ +int8_t stdlib_ndarray_{{SIGNATURE}}_5d_blocked( struct ndarray *arrays[] ); + +/** +* Applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +*/ +int8_t stdlib_ndarray_{{SIGNATURE}}_6d( struct ndarray *arrays[] ); + +/** +* Applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +*/ +int8_t stdlib_ndarray_{{SIGNATURE}}_6d_blocked( struct ndarray *arrays[] ); + +/** +* Applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +*/ +int8_t stdlib_ndarray_{{SIGNATURE}}_7d( struct ndarray *arrays[] ); + +/** +* Applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +*/ +int8_t stdlib_ndarray_{{SIGNATURE}}_7d_blocked( struct ndarray *arrays[] ); + +/** +* Applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +*/ +int8_t stdlib_ndarray_{{SIGNATURE}}_8d( struct ndarray *arrays[] ); + +/** +* Applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +*/ +int8_t stdlib_ndarray_{{SIGNATURE}}_8d_blocked( struct ndarray *arrays[] ); + +/** +* Applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +*/ +int8_t stdlib_ndarray_{{SIGNATURE}}_9d( struct ndarray *arrays[] ); + +/** +* Applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +*/ +int8_t stdlib_ndarray_{{SIGNATURE}}_9d_blocked( struct ndarray *arrays[] ); + +/** +* Applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +*/ +int8_t stdlib_ndarray_{{SIGNATURE}}_10d( struct ndarray *arrays[] ); + +/** +* Applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +*/ +int8_t stdlib_ndarray_{{SIGNATURE}}_10d_blocked( struct ndarray *arrays[] ); + +/** +* Applies a mask to a provided n-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +*/ +int8_t stdlib_ndarray_{{SIGNATURE}}_nd( struct ndarray *arrays[] ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_NDARRAY_BASE_MSKFILTER_{{INCLUDE_GUARD}}_H diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/scripts/templates/source.txt b/lib/node_modules/@stdlib/ndarray/base/mskfilter/scripts/templates/source.txt new file mode 100644 index 00000000000..c6d1dbdeb5a --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/scripts/templates/source.txt @@ -0,0 +1,2298 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) {{YEAR}} {{COPYRIGHT}}. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* +* The following is auto-generated. Do not manually edit. See scripts/loops.js. +*/ + +#include "stdlib/ndarray/base/mskfilter/{{SIGNATURE}}.h" +#include "stdlib/ndarray/base/mskfilter/typedefs.h" +#include "stdlib/ndarray/base/mskfilter/macros.h" +#include "stdlib/ndarray/base/mskfilter/dispatch_object.h" +#include "stdlib/ndarray/base/mskfilter/dispatch.h" +#include "stdlib/ndarray/ctor.h"{{INCLUDES}} +#include + +/** +* Applies a mask to a provided 0-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* ## Notes +* +* - If successful, the functions returns `0`; otherwise, the function returns an error code. +* +* @param arrays array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray and whose third element is a pointer to an output ndarray +* @return status code +* +* @example +* #include "stdlib/ndarray/base/mskfilter/{{SIGNATURE}}.h" +* #include "stdlib/ndarray/dtypes.h" +* #include "stdlib/ndarray/index_modes.h" +* #include "stdlib/ndarray/orders.h" +* #include "stdlib/ndarray/ctor.h"{{EXAMPLE_INCLUDES}} +* #include +* #include +* #include +* +* // Define the ndarray data types: +* enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_{{INPUT_NDARRAY_1_DTYPE_UPPER}}; +* enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +* enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_{{OUTPUT_NDARRAY_DTYPE_UPPER}}; +* +* // Create underlying byte arrays: +* uint8_t xbuf[] = { {{INPUT_NDARRAY_1_BYTES_0D}} }; +* uint8_t mbuf[] = { {{INPUT_NDARRAY_2_BYTES_0D}} }; +* uint8_t ybuf[] = { {{OUTPUT_NDARRAY_BYTES_0D}} }; +* +* // Define the number of dimensions: +* int64_t ndims = 0; +* +* // Define the array shapes: +* int64_t shx[] = { {{INPUT_NDARRAY_SHAPE_0D}} }; +* int64_t shm[] = { {{INPUT_NDARRAY_SHAPE_0D}} }; +* int64_t shy[] = { {{OUTPUT_NDARRAY_SHAPE_0D}} }; +* +* // Define the strides: +* int64_t sx[] = { 0 }; +* int64_t sm[] = { 0 }; +* int64_t sy[] = { 0 }; +* +* // Define the offsets: +* int64_t ox = 0; +* int64_t om = 0; +* int64_t oy = 0; +* +* // Define the array order: +* enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; +* +* // Specify the index mode: +* enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; +* +* // Specify the subscript index modes: +* int8_t submodes[] = { imode }; +* int64_t nsubmodes = 1; +* +* // Create an input ndarray: +* struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +* if ( x == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an mask ndarray: +* struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +* if ( mask == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an output ndarray: +* struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +* if ( y == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an array containing the ndarrays: +* struct ndarray *arrays[] = { x, mask, y }; +* +* // Copy elements: +* int8_t status = stdlib_ndarray_mskfilter_{{SIGNATURE}}_0d( arrays ); +* if ( status != 0 ) { +* fprintf( stderr, "Error during computation.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // ... +* +* // Free allocated memory: +* stdlib_ndarray_free( x ); +* stdlib_ndarray_free( mask ); +* stdlib_ndarray_free( y ); +*/ +int8_t stdlib_ndarray_mskfilter_{{SIGNATURE}}_0d( struct ndarray *arrays[] ) { + int8_t status = stdlib_ndarray_mskfilter_{{SIGNATURE}}_0d( arrays ); + if ( status != 0 ) { + return -1; + } + return 0; +} + +/** +* Applies a mask to a provided 1-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* ## Notes +* +* - If successful, the functions returns `0`; otherwise, the function returns an error code. +* +* @param arrays array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray and whose third element is a pointer to an output ndarray +* @return status code +* +* @example +* #include "stdlib/ndarray/base/mskfilter/{{SIGNATURE}}.h" +* #include "stdlib/ndarray/dtypes.h" +* #include "stdlib/ndarray/index_modes.h" +* #include "stdlib/ndarray/orders.h" +* #include "stdlib/ndarray/ctor.h"{{EXAMPLE_INCLUDES}} +* #include +* #include +* #include +* +* // Define the ndarray data types: +* enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_{{INPUT_NDARRAY_1_DTYPE_UPPER}}; +* enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +* enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_{{OUTPUT_NDARRAY_DTYPE_UPPER}}; +* +* // Create underlying byte arrays: +* uint8_t xbuf[] = { {{INPUT_NDARRAY_1_BYTES_1D}} }; +* uint8_t mbuf[] = { {{INPUT_NDARRAY_2_BYTES_1D}} }; +* uint8_t ybuf[] = { {{OUTPUT_NDARRAY_BYTES_1D}} }; +* +* // Define the number of dimensions: +* int64_t ndims = 1; +* +* // Define the array shapes: +* int64_t shx[] = { {{INPUT_NDARRAY_SHAPE_1D}} }; +* int64_t shm[] = { {{INPUT_NDARRAY_SHAPE_1D}} }; +* int64_t shy[] = { {{OUTPUT_NDARRAY_SHAPE_1D}} }; +* +* // Define the strides: +* int64_t sx[] = { {{INPUT_NDARRAY_1_BYTES_PER_ELEMENT}} }; +* int64_t sm[] = { {{INPUT_NDARRAY_2_BYTES_PER_ELEMENT}} }; +* int64_t sy[] = { {{OUTPUT_NDARRAY_BYTES_PER_ELEMENT}} }; +* +* // Define the offsets: +* int64_t ox = 0; +* int64_t om = 0; +* int64_t oy = 0; +* +* // Define the array order: +* enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; +* +* // Specify the index mode: +* enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; +* +* // Specify the subscript index modes: +* int8_t submodes[] = { imode }; +* int64_t nsubmodes = 1; +* +* // Create an input ndarray: +* struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes ); +* if ( x == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an mask ndarray: +* struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +* if ( mask == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an output ndarray: +* struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shape, sy, oy, order, imode, nsubmodes, submodes ); +* if ( y == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an array containing the ndarrays: +* struct ndarray *arrays[] = { x, mask, y }; +* +* // Copy elements: +* int8_t status = stdlib_ndarray_mskfilter_{{SIGNATURE}}_1d( arrays ); +* if ( status != 0 ) { +* fprintf( stderr, "Error during computation.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // ... +* +* // Free allocated memory: +* stdlib_ndarray_free( x ); +* stdlib_ndarray_free( mask ); +* stdlib_ndarray_free( y ); +*/ +int8_t stdlib_ndarray_mskfilter_{{SIGNATURE}}_1d( struct ndarray *arrays[] ) { + STDLIB_NDARRAY_mskfilter_1D_LOOP_{{LOOP_MACRO}}( {{LOOP_MACRO_ARGUMENTS}} ) + return 0; +} + +/** +* Applies a mask to a provided 2-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* ## Notes +* +* - If successful, the functions returns `0`; otherwise, the function returns an error code. +* +* @param arrays array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray and whose third element is a pointer to an output ndarray +* @return status code +* +* @example +* #include "stdlib/ndarray/base/mskfilter/{{SIGNATURE}}.h" +* #include "stdlib/ndarray/dtypes.h" +* #include "stdlib/ndarray/index_modes.h" +* #include "stdlib/ndarray/orders.h" +* #include "stdlib/ndarray/ctor.h"{{EXAMPLE_INCLUDES}} +* #include +* #include +* #include +* +* // Define the ndarray data types: +* enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_{{INPUT_NDARRAY_1_DTYPE_UPPER}}; +* enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +* enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_{{OUTPUT_NDARRAY_DTYPE_UPPER}}; +* +* // Create underlying byte arrays: +* uint8_t xbuf[] = { {{INPUT_NDARRAY_1_BYTES_2D}} }; +* uint8_t mbuf[] = { {{INPUT_NDARRAY_2_BYTES_2D}} }; +* uint8_t ybuf[] = { {{OUTPUT_NDARRAY_BYTES_2D}} }; +* +* // Define the number of dimensions: +* int64_t ndims = 2; +* +* // Define the array shapes: +* int64_t shx[] = { {{INPUT_NDARRAY_SHAPE_2D}} }; +* int64_t shm[] = { {{INPUT_NDARRAY_SHAPE_2D}} }; +* int64_t shy[] = { {{OUTPUT_NDARRAY_SHAPE_2D}} }; +* +* // Define the strides: +* int64_t sx[] = { {{INPUT_NDARRAY_1_STRIDES_2D}} }; +* int64_t sm[] = { {{INPUT_NDARRAY_2_STRIDES_2D}} }; +* int64_t sy[] = { {{OUTPUT_NDARRAY_STRIDES_2D}} }; +* +* // Define the offsets: +* int64_t ox = 0; +* int64_t om = 0; +* int64_t oy = 0; +* +* // Define the array order: +* enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; +* +* // Specify the index mode: +* enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; +* +* // Specify the subscript index modes: +* int8_t submodes[] = { imode }; +* int64_t nsubmodes = 1; +* +* // Create an input ndarray: +* struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes ); +* if ( x == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an mask ndarray: +* struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +* if ( mask == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an output ndarray: +* struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shape, sy, oy, order, imode, nsubmodes, submodes ); +* if ( y == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an array containing the ndarrays: +* struct ndarray *arrays[] = { x, mask, y }; +* +* // Copy elements: +* int8_t status = stdlib_ndarray_mskfilter_{{SIGNATURE}}_2d( arrays ); +* if ( status != 0 ) { +* fprintf( stderr, "Error during computation.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // ... +* +* // Free allocated memory: +* stdlib_ndarray_free( x ); +* stdlib_ndarray_free( mask ); +* stdlib_ndarray_free( y ); +*/ +int8_t stdlib_ndarray_mskfilter_{{SIGNATURE}}_2d( struct ndarray *arrays[] ) { + STDLIB_NDARRAY_mskfilter_2D_LOOP_{{LOOP_MACRO}}( {{LOOP_MACRO_ARGUMENTS}} ) + return 0; +} + +/** +* Applies a mask to a provided 2-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* ## Notes +* +* - If successful, the functions returns `0`; otherwise, the function returns an error code. +* +* @param arrays array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray and whose third element is a pointer to an output ndarray +* @return status code +* +* @example +* #include "stdlib/ndarray/base/mskfilter/{{SIGNATURE}}.h" +* #include "stdlib/ndarray/dtypes.h" +* #include "stdlib/ndarray/index_modes.h" +* #include "stdlib/ndarray/orders.h" +* #include "stdlib/ndarray/ctor.h"{{EXAMPLE_INCLUDES}} +* #include +* #include +* #include +* +* // Define the ndarray data types: +* enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_{{INPUT_NDARRAY_1_DTYPE_UPPER}}; +* enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +* enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_{{OUTPUT_NDARRAY_DTYPE_UPPER}}; +* +* // Create underlying byte arrays: +* // Create underlying byte arrays: +* uint8_t xbuf[] = { {{INPUT_NDARRAY_1_BYTES_2D}} }; +* uint8_t mbuf[] = { {{INPUT_NDARRAY_2_BYTES_2D}} }; +* uint8_t ybuf[] = { {{OUTPUT_NDARRAY_BYTES_2D}} }; +* +* // Define the number of dimensions: +* int64_t ndims = 2; +* +* // Define the array shapes: +* int64_t shx[] = { {{INPUT_NDARRAY_SHAPE_2D}} }; +* int64_t shm[] = { {{INPUT_NDARRAY_SHAPE_2D}} }; +* int64_t shy[] = { {{OUTPUT_NDARRAY_SHAPE_2D}} }; +* +* // Define the strides: +* int64_t sx[] = { {{INPUT_NDARRAY_1_STRIDES_2D}} }; +* int64_t sm[] = { {{INPUT_NDARRAY_2_STRIDES_2D}} }; +* int64_t sy[] = { {{OUTPUT_NDARRAY_STRIDES_2D}} }; +* +* // Define the offsets: +* int64_t ox = 0; +* int64_t om = 0; +* int64_t oy = 0; +* +* // Define the array order: +* enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; +* +* // Specify the index mode: +* enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; +* +* // Specify the subscript index modes: +* int8_t submodes[] = { imode }; +* int64_t nsubmodes = 1; +* +* // Create an input ndarray: +* struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes ); +* if ( x == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an mask ndarray: +* struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +* if ( mask == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an output ndarray: +* struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shape, sy, oy, order, imode, nsubmodes, submodes ); +* if ( y == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an array containing the ndarrays: +* struct ndarray *arrays[] = { x, mask, y }; +* +* // Copy elements: +* int8_t status = stdlib_ndarray_mskfilter_{{SIGNATURE}}_2d_blocked( arrays ); +* if ( status != 0 ) { +* fprintf( stderr, "Error during computation.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // ... +* +* // Free allocated memory: +* stdlib_ndarray_free( x ); +* stdlib_ndarray_free( mask ); +* stdlib_ndarray_free( y ); +*/ +int8_t stdlib_ndarray_mskfilter_{{SIGNATURE}}_2d_blocked( struct ndarray *arrays[] ) { + STDLIB_NDARRAY_mskfilter_2D_BLOCKED_LOOP_{{LOOP_MACRO}}( {{LOOP_MACRO_ARGUMENTS}} ) + return 0; +} + +/** +* Applies a mask to a provided 3-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* ## Notes +* +* - If successful, the functions returns `0`; otherwise, the function returns an error code. +* +* @param arrays array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray and whose third element is a pointer to an output ndarray +* @return status code +* +* @example +* #include "stdlib/ndarray/base/mskfilter/{{SIGNATURE}}.h" +* #include "stdlib/ndarray/dtypes.h" +* #include "stdlib/ndarray/index_modes.h" +* #include "stdlib/ndarray/orders.h" +* #include "stdlib/ndarray/ctor.h"{{EXAMPLE_INCLUDES}} +* #include +* #include +* #include +* +* // Define the ndarray data types: +* enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_{{INPUT_NDARRAY_1_DTYPE_UPPER}}; +* enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +* enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_{{OUTPUT_NDARRAY_DTYPE_UPPER}}; +* +* // Create underlying byte arrays: +* uint8_t xbuf[] = { {{INPUT_NDARRAY_1_BYTES_3D}} }; +* uint8_t mbuf[] = { {{INPUT_NDARRAY_2_BYTES_3D}} }; +* uint8_t ybuf[] = { {{OUTPUT_NDARRAY_BYTES_3D}} }; +* +* // Define the number of dimensions: +* int64_t ndims = 3; +* +* // Define the array shapes: +* int64_t shx[] = { {{INPUT_NDARRAY_SHAPE_3D}} }; +* int64_t shm[] = { {{INPUT_NDARRAY_SHAPE_3D}} }; +* int64_t shy[] = { {{OUTPUT_NDARRAY_SHAPE_3D}} }; +* +* // Define the strides: +* int64_t sx[] = { {{INPUT_NDARRAY_1_STRIDES_3D}} }; +* int64_t sm[] = { {{INPUT_NDARRAY_2_STRIDES_3D}} }; +* int64_t sy[] = { {{OUTPUT_NDARRAY_STRIDES_3D}} }; +* +* // Define the offsets: +* int64_t ox = 0; +* int64_t om = 0; +* int64_t oy = 0; +* +* // Define the array order: +* enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; +* +* // Specify the index mode: +* enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; +* +* // Specify the subscript index modes: +* int8_t submodes[] = { imode }; +* int64_t nsubmodes = 1; +* +* // Create an input ndarray: +* struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes ); +* if ( x == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an mask ndarray: +* struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +* if ( mask == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an output ndarray: +* struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shape, sy, oy, order, imode, nsubmodes, submodes ); +* if ( y == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an array containing the ndarrays: +* struct ndarray *arrays[] = { x, mask, y }; +* +* // Copy elements: +* int8_t status = stdlib_ndarray_mskfilter_{{SIGNATURE}}_3d( arrays ); +* if ( status != 0 ) { +* fprintf( stderr, "Error during computation.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // ... +* +* // Free allocated memory: +* stdlib_ndarray_free( x ); +* stdlib_ndarray_free( mask ); +* stdlib_ndarray_free( y ); +*/ +int8_t stdlib_ndarray_mskfilter_{{SIGNATURE}}_3d( struct ndarray *arrays[] ) { + STDLIB_NDARRAY_mskfilter_3D_LOOP_{{LOOP_MACRO}}( {{LOOP_MACRO_ARGUMENTS}} ) + return 0; +} + +/** +* Applies a mask to a provided 3-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* ## Notes +* +* - If successful, the functions returns `0`; otherwise, the function returns an error code. +* +* @param arrays array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray and whose third element is a pointer to an output ndarray +* @return status code +* +* @example +* #include "stdlib/ndarray/base/mskfilter/{{SIGNATURE}}.h" +* #include "stdlib/ndarray/dtypes.h" +* #include "stdlib/ndarray/index_modes.h" +* #include "stdlib/ndarray/orders.h" +* #include "stdlib/ndarray/ctor.h"{{EXAMPLE_INCLUDES}} +* #include +* #include +* #include +* +* // Define the ndarray data types: +* enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_{{INPUT_NDARRAY_1_DTYPE_UPPER}}; +* enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +* enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_{{OUTPUT_NDARRAY_DTYPE_UPPER}}; +* +* // Create underlying byte arrays: +* uint8_t xbuf[] = { {{INPUT_NDARRAY_1_BYTES_3D}} }; +* uint8_t mbuf[] = { {{INPUT_NDARRAY_2_BYTES_3D}} }; +* uint8_t ybuf[] = { {{OUTPUT_NDARRAY_BYTES_3D}} }; +* +* // Define the number of dimensions: +* int64_t ndims = 3; +* +* // Define the array shapes: +* int64_t shx[] = { {{INPUT_NDARRAY_SHAPE_3D}} }; +* int64_t shm[] = { {{INPUT_NDARRAY_SHAPE_3D}} }; +* int64_t shy[] = { {{OUTPUT_NDARRAY_SHAPE_3D}} }; +* +* // Define the strides: +* int64_t sx[] = { {{INPUT_NDARRAY_1_STRIDES_3D}} }; +* int64_t sm[] = { {{INPUT_NDARRAY_2_STRIDES_3D}} }; +* int64_t sy[] = { {{OUTPUT_NDARRAY_STRIDES_3D}} }; +* +* // Define the offsets: +* int64_t ox = 0; +* int64_t om = 0; +* int64_t oy = 0; +* +* // Define the array order: +* enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; +* +* // Specify the index mode: +* enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; +* +* // Specify the subscript index modes: +* int8_t submodes[] = { imode }; +* int64_t nsubmodes = 1; +* +* // Create an input ndarray: +* struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes ); +* if ( x == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an mask ndarray: +* struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +* if ( mask == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an output ndarray: +* struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shape, sy, oy, order, imode, nsubmodes, submodes ); +* if ( y == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an array containing the ndarrays: +* struct ndarray *arrays[] = { x, mask, y }; +* +* // Copy elements: +* int8_t status = stdlib_ndarray_mskfilter_{{SIGNATURE}}_3d_blocked( arrays ); +* if ( status != 0 ) { +* fprintf( stderr, "Error during computation.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // ... +* +* // Free allocated memory: +* stdlib_ndarray_free( x ); +* stdlib_ndarray_free( mask ); +* stdlib_ndarray_free( y ); +*/ +int8_t stdlib_ndarray_mskfilter_{{SIGNATURE}}_3d_blocked( struct ndarray *arrays[] ) { + STDLIB_NDARRAY_mskfilter_3D_BLOCKED_LOOP_{{LOOP_MACRO}}( {{LOOP_MACRO_ARGUMENTS}} ) + return 0; +} + +/** +* Applies a mask to a provided 4-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* ## Notes +* +* - If successful, the functions returns `0`; otherwise, the function returns an error code. +* +* @param arrays array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray and whose third element is a pointer to an output ndarray +* @return status code +* +* @example +* #include "stdlib/ndarray/base/mskfilter/{{SIGNATURE}}.h" +* #include "stdlib/ndarray/dtypes.h" +* #include "stdlib/ndarray/index_modes.h" +* #include "stdlib/ndarray/orders.h" +* #include "stdlib/ndarray/ctor.h"{{EXAMPLE_INCLUDES}} +* #include +* #include +* #include +* +* // Define the ndarray data types: +* enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_{{INPUT_NDARRAY_1_DTYPE_UPPER}}; +* enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +* enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_{{OUTPUT_NDARRAY_DTYPE_UPPER}}; +* +* // Create underlying byte arrays: +* uint8_t xbuf[] = { {{INPUT_NDARRAY_1_BYTES_4D}} }; +* uint8_t mbuf[] = { {{INPUT_NDARRAY_2_BYTES_4D}} }; +* uint8_t ybuf[] = { {{OUTPUT_NDARRAY_BYTES_4D}} }; +* +* // Define the number of dimensions: +* int64_t ndims = 4; +* +* // Define the array shapes: +* int64_t shx[] = { {{INPUT_NDARRAY_SHAPE_4D}} }; +* int64_t shm[] = { {{INPUT_NDARRAY_SHAPE_4D}} }; +* int64_t shy[] = { {{OUTPUT_NDARRAY_SHAPE_4D}} }; +* +* // Define the strides: +* int64_t sx[] = { {{INPUT_NDARRAY_1_STRIDES_4D}} }; +* int64_t sm[] = { {{INPUT_NDARRAY_2_STRIDES_4D}} }; +* int64_t sy[] = { {{OUTPUT_NDARRAY_STRIDES_4D}} }; +* +* // Define the offsets: +* int64_t ox = 0; +* int64_t om = 0; +* int64_t oy = 0; +* +* // Define the array order: +* enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; +* +* // Specify the index mode: +* enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; +* +* // Specify the subscript index modes: +* int8_t submodes[] = { imode }; +* int64_t nsubmodes = 1; +* +* // Create an input ndarray: +* struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes ); +* if ( x == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an mask ndarray: +* struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +* if ( mask == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an output ndarray: +* struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shape, sy, oy, order, imode, nsubmodes, submodes ); +* if ( y == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an array containing the ndarrays: +* struct ndarray *arrays[] = { x, mask, y }; +* +* // Copy elements: +* int8_t status = stdlib_ndarray_mskfilter_{{SIGNATURE}}_4d( arrays ); +* if ( status != 0 ) { +* fprintf( stderr, "Error during computation.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // ... +* +* // Free allocated memory: +* stdlib_ndarray_free( x ); +* stdlib_ndarray_free( mask ); +* stdlib_ndarray_free( y ); +*/ +int8_t stdlib_ndarray_mskfilter_{{SIGNATURE}}_4d( struct ndarray *arrays[] ) { + STDLIB_NDARRAY_mskfilter_4D_LOOP_{{LOOP_MACRO}}( {{LOOP_MACRO_ARGUMENTS}} ) + return 0; +} + +/** +* Applies a mask to a provided 4-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* ## Notes +* +* - If successful, the functions returns `0`; otherwise, the function returns an error code. +* +* @param arrays array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray and whose third element is a pointer to an output ndarray +* @return status code +* +* @example +* #include "stdlib/ndarray/base/mskfilter/{{SIGNATURE}}.h" +* #include "stdlib/ndarray/dtypes.h" +* #include "stdlib/ndarray/index_modes.h" +* #include "stdlib/ndarray/orders.h" +* #include "stdlib/ndarray/ctor.h"{{EXAMPLE_INCLUDES}} +* #include +* #include +* #include +* +* // Define the ndarray data types: +* enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_{{INPUT_NDARRAY_1_DTYPE_UPPER}}; +* enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +* enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_{{OUTPUT_NDARRAY_DTYPE_UPPER}}; +* +* // Create underlying byte arrays: +* uint8_t xbuf[] = { {{INPUT_NDARRAY_1_BYTES_4D}} }; +* uint8_t mbuf[] = { {{INPUT_NDARRAY_2_BYTES_4D}} }; +* uint8_t ybuf[] = { {{OUTPUT_NDARRAY_BYTES_4D}} }; +* +* // Define the number of dimensions: +* int64_t ndims = 4; +* +* // Define the array shapes: +* int64_t shx[] = { {{INPUT_NDARRAY_SHAPE_4D}} }; +* int64_t shm[] = { {{INPUT_NDARRAY_SHAPE_4D}} }; +* int64_t shy[] = { {{OUTPUT_NDARRAY_SHAPE_4D}} }; +* +* // Define the strides: +* int64_t sx[] = { {{INPUT_NDARRAY_1_STRIDES_4D}} }; +* int64_t sm[] = { {{INPUT_NDARRAY_2_STRIDES_4D}} }; +* int64_t sy[] = { {{OUTPUT_NDARRAY_STRIDES_4D}} }; +* +* // Define the offsets: +* int64_t ox = 0; +* int64_t om = 0; +* int64_t oy = 0; +* +* // Define the array order: +* enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; +* +* // Specify the index mode: +* enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; +* +* // Specify the subscript index modes: +* int8_t submodes[] = { imode }; +* int64_t nsubmodes = 1; +* +* // Create an input ndarray: +* struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes ); +* if ( x == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an mask ndarray: +* struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +* if ( mask == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an output ndarray: +* struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shape, sy, oy, order, imode, nsubmodes, submodes ); +* if ( y == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an array containing the ndarrays: +* struct ndarray *arrays[] = { x, mask, y }; +* +* // Copy elements: +* int8_t status = stdlib_ndarray_mskfilter_{{SIGNATURE}}_4d_blocked( arrays ); +* if ( status != 0 ) { +* fprintf( stderr, "Error during computation.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // ... +* +* // Free allocated memory: +* stdlib_ndarray_free( x ); +* stdlib_ndarray_free( mask ); +* stdlib_ndarray_free( y ); +*/ +int8_t stdlib_ndarray_mskfilter_{{SIGNATURE}}_4d_blocked( struct ndarray *arrays[] ) { + STDLIB_NDARRAY_mskfilter_4D_BLOCKED_LOOP_{{LOOP_MACRO}}( {{LOOP_MACRO_ARGUMENTS}} ) + return 0; +} + +/** +* Applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* ## Notes +* +* - If successful, the functions returns `0`; otherwise, the function returns an error code. +* +* @param arrays array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray and whose third element is a pointer to an output ndarray +* @return status code +* +* @example +* #include "stdlib/ndarray/base/mskfilter/{{SIGNATURE}}.h" +* #include "stdlib/ndarray/dtypes.h" +* #include "stdlib/ndarray/index_modes.h" +* #include "stdlib/ndarray/orders.h" +* #include "stdlib/ndarray/ctor.h"{{EXAMPLE_INCLUDES}} +* #include +* #include +* #include +* +* // Define the ndarray data types: +* enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_{{INPUT_NDARRAY_1_DTYPE_UPPER}}; +* enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +* enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_{{OUTPUT_NDARRAY_DTYPE_UPPER}}; +* +* // Create underlying byte arrays: +* uint8_t xbuf[] = { {{INPUT_NDARRAY_1_BYTES_5D}} }; +* uint8_t mbuf[] = { {{INPUT_NDARRAY_2_BYTES_5D}} }; +* uint8_t ybuf[] = { {{OUTPUT_NDARRAY_BYTES_5D}} }; +* +* // Define the number of dimensions: +* int64_t ndims = 5; +* +* // Define the array shapes: +* int64_t shx[] = { {{INPUT_NDARRAY_SHAPE_5D}} }; +* int64_t shm[] = { {{INPUT_NDARRAY_SHAPE_5D}} }; +* int64_t shy[] = { {{OUTPUT_NDARRAY_SHAPE_5D}} }; +* +* // Define the strides: +* int64_t sx[] = { {{INPUT_NDARRAY_1_STRIDES_5D}} }; +* int64_t sm[] = { {{INPUT_NDARRAY_2_STRIDES_5D}} }; +* int64_t sy[] = { {{OUTPUT_NDARRAY_STRIDES_5D}} }; +* +* // Define the offsets: +* int64_t ox = 0; +* int64_t om = 0; +* int64_t oy = 0; +* +* // Define the array order: +* enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; +* +* // Specify the index mode: +* enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; +* +* // Specify the subscript index modes: +* int8_t submodes[] = { imode }; +* int64_t nsubmodes = 1; +* +* // Create an input ndarray: +* struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes ); +* if ( x == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an mask ndarray: +* struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +* if ( mask == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an output ndarray: +* struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shape, sy, oy, order, imode, nsubmodes, submodes ); +* if ( y == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an array containing the ndarrays: +* struct ndarray *arrays[] = { x, mask, y }; +* +* // Copy elements: +* int8_t status = stdlib_ndarray_mskfilter_{{SIGNATURE}}_5d( arrays ); +* if ( status != 0 ) { +* fprintf( stderr, "Error during computation.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // ... +* +* // Free allocated memory: +* stdlib_ndarray_free( x ); +* stdlib_ndarray_free( mask ); +* stdlib_ndarray_free( y ); +*/ +int8_t stdlib_ndarray_mskfilter_{{SIGNATURE}}_5d( struct ndarray *arrays[] ) { + STDLIB_NDARRAY_mskfilter_5D_LOOP_{{LOOP_MACRO}}( {{LOOP_MACRO_ARGUMENTS}} ) + return 0; +} + +/** +* Applies a mask to a provided 5-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* ## Notes +* +* - If successful, the functions returns `0`; otherwise, the function returns an error code. +* +* @param arrays array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray and whose third element is a pointer to an output ndarray +* @return status code +* +* @example +* #include "stdlib/ndarray/base/mskfilter/{{SIGNATURE}}.h" +* #include "stdlib/ndarray/dtypes.h" +* #include "stdlib/ndarray/index_modes.h" +* #include "stdlib/ndarray/orders.h" +* #include "stdlib/ndarray/ctor.h"{{EXAMPLE_INCLUDES}} +* #include +* #include +* #include +* +* // Define the ndarray data types: +* enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_{{INPUT_NDARRAY_1_DTYPE_UPPER}}; +* enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +* enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_{{OUTPUT_NDARRAY_DTYPE_UPPER}}; +* +* // Create underlying byte arrays: +* uint8_t xbuf[] = { {{INPUT_NDARRAY_1_BYTES_5D}} }; +* uint8_t mbuf[] = { {{INPUT_NDARRAY_2_BYTES_5D}} }; +* uint8_t ybuf[] = { {{OUTPUT_NDARRAY_BYTES_5D}} }; +* +* // Define the number of dimensions: +* int64_t ndims = 5; +* +* // Define the array shapes: +* int64_t shx[] = { {{INPUT_NDARRAY_SHAPE_5D}} }; +* int64_t shm[] = { {{INPUT_NDARRAY_SHAPE_5D}} }; +* int64_t shy[] = { {{OUTPUT_NDARRAY_SHAPE_5D}} }; +* +* // Define the strides: +* int64_t sx[] = { {{INPUT_NDARRAY_1_STRIDES_5D}} }; +* int64_t sm[] = { {{INPUT_NDARRAY_2_STRIDES_5D}} }; +* int64_t sy[] = { {{OUTPUT_NDARRAY_STRIDES_5D}} }; +* +* // Define the offsets: +* int64_t ox = 0; +* int64_t om = 0; +* int64_t oy = 0; +* +* // Define the array order: +* enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; +* +* // Specify the index mode: +* enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; +* +* // Specify the subscript index modes: +* int8_t submodes[] = { imode }; +* int64_t nsubmodes = 1; +* +* // Create an input ndarray: +* struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes ); +* if ( x == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an mask ndarray: +* struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +* if ( mask == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an output ndarray: +* struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shape, sy, oy, order, imode, nsubmodes, submodes ); +* if ( y == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an array containing the ndarrays: +* struct ndarray *arrays[] = { x, mask, y }; +* +* // Copy elements: +* int8_t status = stdlib_ndarray_mskfilter_{{SIGNATURE}}_5d_blocked( arrays ); +* if ( status != 0 ) { +* fprintf( stderr, "Error during computation.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // ... +* +* // Free allocated memory: +* stdlib_ndarray_free( x ); +* stdlib_ndarray_free( mask ); +* stdlib_ndarray_free( y ); +*/ +int8_t stdlib_ndarray_mskfilter_{{SIGNATURE}}_5d_blocked( struct ndarray *arrays[] ) { + STDLIB_NDARRAY_mskfilter_5D_BLOCKED_LOOP_{{LOOP_MACRO}}( {{LOOP_MACRO_ARGUMENTS}} ) + return 0; +} + +/** +* Applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* ## Notes +* +* - If successful, the functions returns `0`; otherwise, the function returns an error code. +* +* @param arrays array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray and whose third element is a pointer to an output ndarray +* @return status code +* +* @example +* #include "stdlib/ndarray/base/mskfilter/{{SIGNATURE}}.h" +* #include "stdlib/ndarray/dtypes.h" +* #include "stdlib/ndarray/index_modes.h" +* #include "stdlib/ndarray/orders.h" +* #include "stdlib/ndarray/ctor.h"{{EXAMPLE_INCLUDES}} +* #include +* #include +* #include +* +* // Define the ndarray data types: +* enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_{{INPUT_NDARRAY_1_DTYPE_UPPER}}; +* enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +* enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_{{OUTPUT_NDARRAY_DTYPE_UPPER}}; +* +* // Create underlying byte arrays: +* uint8_t xbuf[] = { {{INPUT_NDARRAY_1_BYTES_6D}} }; +* uint8_t mbuf[] = { {{INPUT_NDARRAY_2_BYTES_6D}} }; +* uint8_t ybuf[] = { {{OUTPUT_NDARRAY_BYTES_6D}} }; +* +* // Define the number of dimensions: +* int64_t ndims = 6; +* +* // Define the array shapes: +* int64_t shx[] = { {{INPUT_NDARRAY_SHAPE_6D}} }; +* int64_t shm[] = { {{INPUT_NDARRAY_SHAPE_6D}} }; +* int64_t shy[] = { {{OUTPUT_NDARRAY_SHAPE_6D}} }; +* +* // Define the strides: +* int64_t sx[] = { {{INPUT_NDARRAY_1_STRIDES_6D}} }; +* int64_t sm[] = { {{INPUT_NDARRAY_2_STRIDES_6D}} }; +* int64_t sy[] = { {{OUTPUT_NDARRAY_STRIDES_6D}} }; +* +* // Define the offsets: +* int64_t ox = 0; +* int64_t om = 0; +* int64_t oy = 0; +* +* // Define the array order: +* enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; +* +* // Specify the index mode: +* enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; +* +* // Specify the subscript index modes: +* int8_t submodes[] = { imode }; +* int64_t nsubmodes = 1; +* +* // Create an input ndarray: +* struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes ); +* if ( x == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an mask ndarray: +* struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +* if ( mask == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an output ndarray: +* struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shape, sy, oy, order, imode, nsubmodes, submodes ); +* if ( y == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an array containing the ndarrays: +* struct ndarray *arrays[] = { x, mask, y }; +* +* // Copy elements: +* int8_t status = stdlib_ndarray_mskfilter_{{SIGNATURE}}_6d( arrays ); +* if ( status != 0 ) { +* fprintf( stderr, "Error during computation.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // ... +* +* // Free allocated memory: +* stdlib_ndarray_free( x ); +* stdlib_ndarray_free( mask ); +* stdlib_ndarray_free( y ); +*/ +int8_t stdlib_ndarray_mskfilter_{{SIGNATURE}}_6d( struct ndarray *arrays[] ) { + STDLIB_NDARRAY_mskfilter_6D_LOOP_{{LOOP_MACRO}}( {{LOOP_MACRO_ARGUMENTS}} ) + return 0; +} + +/** +* Applies a mask to a provided 6-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* ## Notes +* +* - If successful, the functions returns `0`; otherwise, the function returns an error code. +* +* @param arrays array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray and whose third element is a pointer to an output ndarray +* @return status code +* +* @example +* #include "stdlib/ndarray/base/mskfilter/{{SIGNATURE}}.h" +* #include "stdlib/ndarray/dtypes.h" +* #include "stdlib/ndarray/index_modes.h" +* #include "stdlib/ndarray/orders.h" +* #include "stdlib/ndarray/ctor.h"{{EXAMPLE_INCLUDES}} +* #include +* #include +* #include +* +* // Define the ndarray data types: +* enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_{{INPUT_NDARRAY_1_DTYPE_UPPER}}; +* enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +* enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_{{OUTPUT_NDARRAY_DTYPE_UPPER}}; +* +* // Create underlying byte arrays: +* uint8_t xbuf[] = { {{INPUT_NDARRAY_1_BYTES_6D}} }; +* uint8_t mbuf[] = { {{INPUT_NDARRAY_2_BYTES_6D}} }; +* uint8_t ybuf[] = { {{OUTPUT_NDARRAY_BYTES_6D}} }; +* +* // Define the number of dimensions: +* int64_t ndims = 6; +* +* // Define the array shapes: +* int64_t shx[] = { {{INPUT_NDARRAY_SHAPE_6D}} }; +* int64_t shm[] = { {{INPUT_NDARRAY_SHAPE_6D}} }; +* int64_t shy[] = { {{OUTPUT_NDARRAY_SHAPE_6D}} }; +* +* // Define the strides: +* int64_t sx[] = { {{INPUT_NDARRAY_1_STRIDES_6D}} }; +* int64_t sm[] = { {{INPUT_NDARRAY_2_STRIDES_6D}} }; +* int64_t sy[] = { {{OUTPUT_NDARRAY_STRIDES_6D}} }; +* +* // Define the offsets: +* int64_t ox = 0; +* int64_t om = 0; +* int64_t oy = 0; +* +* // Define the array order: +* enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; +* +* // Specify the index mode: +* enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; +* +* // Specify the subscript index modes: +* int8_t submodes[] = { imode }; +* int64_t nsubmodes = 1; +* +* // Create an input ndarray: +* struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes ); +* if ( x == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an output ndarray: +* struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shape, sy, oy, order, imode, nsubmodes, submodes ); +* if ( y == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an mask ndarray: +* struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +* if ( mask == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an array containing the ndarrays: +* struct ndarray *arrays[] = { x, mask, y }; +* +* // Copy elements: +* int8_t status = stdlib_ndarray_mskfilter_{{SIGNATURE}}_6d_blocked( arrays ); +* if ( status != 0 ) { +* fprintf( stderr, "Error during computation.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // ... +* +* // Free allocated memory: +* stdlib_ndarray_free( x ); +* stdlib_ndarray_free( mask ); +* stdlib_ndarray_free( y ); +*/ +int8_t stdlib_ndarray_mskfilter_{{SIGNATURE}}_6d_blocked( struct ndarray *arrays[] ) { + STDLIB_NDARRAY_mskfilter_6D_BLOCKED_LOOP_{{LOOP_MACRO}}( {{LOOP_MACRO_ARGUMENTS}} ) + return 0; +} + +/** +* Applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* ## Notes +* +* - If successful, the functions returns `0`; otherwise, the function returns an error code. +* +* @param arrays array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray and whose third element is a pointer to an output ndarray +* @return status code +* +* @example +* #include "stdlib/ndarray/base/mskfilter/{{SIGNATURE}}.h" +* #include "stdlib/ndarray/dtypes.h" +* #include "stdlib/ndarray/index_modes.h" +* #include "stdlib/ndarray/orders.h" +* #include "stdlib/ndarray/ctor.h"{{EXAMPLE_INCLUDES}} +* #include +* #include +* #include +* +* // Define the ndarray data types: +* enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_{{INPUT_NDARRAY_1_DTYPE_UPPER}}; +* enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +* enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_{{OUTPUT_NDARRAY_DTYPE_UPPER}}; +* +* // Create underlying byte arrays: +* uint8_t xbuf[] = { {{INPUT_NDARRAY_1_BYTES_7D}} }; +* uint8_t mbuf[] = { {{INPUT_NDARRAY_2_BYTES_7D}} }; +* uint8_t ybuf[] = { {{OUTPUT_NDARRAY_BYTES_7D}} }; +* +* // Define the number of dimensions: +* int64_t ndims = 7; +* +* // Define the array shapes: +* int64_t shx[] = { {{INPUT_NDARRAY_SHAPE_7D}} }; +* int64_t shm[] = { {{INPUT_NDARRAY_SHAPE_7D}} }; +* int64_t shy[] = { {{OUTPUT_NDARRAY_SHAPE_7D}} }; +* +* // Define the strides: +* int64_t sx[] = { {{INPUT_NDARRAY_1_STRIDES_7D}} }; +* int64_t sm[] = { {{INPUT_NDARRAY_2_STRIDES_7D}} }; +* int64_t sy[] = { {{OUTPUT_NDARRAY_STRIDES_7D}} }; +* +* // Define the offsets: +* int64_t ox = 0; +* int64_t om = 0; +* int64_t oy = 0; +* +* // Define the array order: +* enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; +* +* // Specify the index mode: +* enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; +* +* // Specify the subscript index modes: +* int8_t submodes[] = { imode }; +* int64_t nsubmodes = 1; +* +* // Create an input ndarray: +* struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes ); +* if ( x == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an mask ndarray: +* struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +* if ( mask == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an output ndarray: +* struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shape, sy, oy, order, imode, nsubmodes, submodes ); +* if ( y == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an array containing the ndarrays: +* struct ndarray *arrays[] = { x, mask, y }; +* +* // Copy elements: +* int8_t status = stdlib_ndarray_mskfilter_{{SIGNATURE}}_7d( arrays ); +* if ( status != 0 ) { +* fprintf( stderr, "Error during computation.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // ... +* +* // Free allocated memory: +* stdlib_ndarray_free( x ); +* stdlib_ndarray_free( mask ); +* stdlib_ndarray_free( y ); +*/ +int8_t stdlib_ndarray_mskfilter_{{SIGNATURE}}_7d( struct ndarray *arrays[] ) { + STDLIB_NDARRAY_mskfilter_7D_LOOP_{{LOOP_MACRO}}( {{LOOP_MACRO_ARGUMENTS}} ) + return 0; +} + +/** +* Applies a mask to a provided 7-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* ## Notes +* +* - If successful, the functions returns `0`; otherwise, the function returns an error code. +* +* @param arrays array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray and whose third element is a pointer to an output ndarray +* @return status code +* +* @example +* #include "stdlib/ndarray/base/mskfilter/{{SIGNATURE}}.h" +* #include "stdlib/ndarray/dtypes.h" +* #include "stdlib/ndarray/index_modes.h" +* #include "stdlib/ndarray/orders.h" +* #include "stdlib/ndarray/ctor.h"{{EXAMPLE_INCLUDES}} +* #include +* #include +* #include +* +* // Define the ndarray data types: +* enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_{{INPUT_NDARRAY_1_DTYPE_UPPER}}; +* enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +* enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_{{OUTPUT_NDARRAY_DTYPE_UPPER}}; +* +* // Create underlying byte arrays: +* uint8_t xbuf[] = { {{INPUT_NDARRAY_1_BYTES_7D}} }; +* uint8_t mbuf[] = { {{INPUT_NDARRAY_2_BYTES_7D}} }; +* uint8_t ybuf[] = { {{OUTPUT_NDARRAY_BYTES_7D}} }; +* +* // Define the number of dimensions: +* int64_t ndims = 7; +* +* // Define the array shapes: +* int64_t shx[] = { {{INPUT_NDARRAY_SHAPE_7D}} }; +* int64_t shm[] = { {{INPUT_NDARRAY_SHAPE_7D}} }; +* int64_t shy[] = { {{OUTPUT_NDARRAY_SHAPE_7D}} }; +* +* // Define the strides: +* int64_t sx[] = { {{INPUT_NDARRAY_1_STRIDES_7D}} }; +* int64_t sm[] = { {{INPUT_NDARRAY_2_STRIDES_7D}} }; +* int64_t sy[] = { {{OUTPUT_NDARRAY_STRIDES_7D}} }; +* +* // Define the offsets: +* int64_t ox = 0; +* int64_t om = 0; +* int64_t oy = 0; +* +* // Define the array order: +* enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; +* +* // Specify the index mode: +* enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; +* +* // Specify the subscript index modes: +* int8_t submodes[] = { imode }; +* int64_t nsubmodes = 1; +* +* // Create an input ndarray: +* struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes ); +* if ( x == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an mask ndarray: +* struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +* if ( mask == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an output ndarray: +* struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shape, sy, oy, order, imode, nsubmodes, submodes ); +* if ( y == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an array containing the ndarrays: +* struct ndarray *arrays[] = { x, mask, y }; +* +* // Copy elements: +* int8_t status = stdlib_ndarray_mskfilter_{{SIGNATURE}}_7d_blocked( arrays ); +* if ( status != 0 ) { +* fprintf( stderr, "Error during computation.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // ... +* +* // Free allocated memory: +* stdlib_ndarray_free( x ); +* stdlib_ndarray_free( mask ); +* stdlib_ndarray_free( y ); +*/ +int8_t stdlib_ndarray_mskfilter_{{SIGNATURE}}_7d_blocked( struct ndarray *arrays[] ) { + STDLIB_NDARRAY_mskfilter_7D_BLOCKED_LOOP_{{LOOP_MACRO}}( {{LOOP_MACRO_ARGUMENTS}} ) + return 0; +} + +/** +* Applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* ## Notes +* +* - If successful, the functions returns `0`; otherwise, the function returns an error code. +* +* @param arrays array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray and whose third element is a pointer to an output ndarray +* @return status code +* +* @example +* #include "stdlib/ndarray/base/mskfilter/{{SIGNATURE}}.h" +* #include "stdlib/ndarray/dtypes.h" +* #include "stdlib/ndarray/index_modes.h" +* #include "stdlib/ndarray/orders.h" +* #include "stdlib/ndarray/ctor.h"{{EXAMPLE_INCLUDES}} +* #include +* #include +* #include +* +* // Define the ndarray data types: +* enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_{{INPUT_NDARRAY_1_DTYPE_UPPER}}; +* enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +* enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_{{OUTPUT_NDARRAY_DTYPE_UPPER}}; +* +* // Create underlying byte arrays: +* uint8_t xbuf[] = { {{INPUT_NDARRAY_1_BYTES_8D}} }; +* uint8_t mbuf[] = { {{INPUT_NDARRAY_2_BYTES_8D}} }; +* uint8_t ybuf[] = { {{OUTPUT_NDARRAY_BYTES_8D}} }; +* +* // Define the number of dimensions: +* int64_t ndims = 8; +* +* // Define the array shapes: +* int64_t shx[] = { {{INPUT_NDARRAY_SHAPE_8D}} }; +* int64_t shm[] = { {{INPUT_NDARRAY_SHAPE_8D}} }; +* int64_t shy[] = { {{OUTPUT_NDARRAY_SHAPE_8D}} }; +* +* // Define the strides: +* int64_t sx[] = { {{INPUT_NDARRAY_1_STRIDES_8D}} }; +* int64_t sm[] = { {{INPUT_NDARRAY_2_STRIDES_8D}} }; +* int64_t sy[] = { {{OUTPUT_NDARRAY_STRIDES_8D}} }; +* +* // Define the offsets: +* int64_t ox = 0; +* int64_t om = 0; +* int64_t oy = 0; +* +* // Define the array order: +* enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; +* +* // Specify the index mode: +* enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; +* +* // Specify the subscript index modes: +* int8_t submodes[] = { imode }; +* int64_t nsubmodes = 1; +* +* // Create an input ndarray: +* struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes ); +* if ( x == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an mask ndarray: +* struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +* if ( mask == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an output ndarray: +* struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shape, sy, oy, order, imode, nsubmodes, submodes ); +* if ( y == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an array containing the ndarrays: +* struct ndarray *arrays[] = { x, mask, y }; +* +* // Copy elements: +* int8_t status = stdlib_ndarray_mskfilter_{{SIGNATURE}}_8d( arrays ); +* if ( status != 0 ) { +* fprintf( stderr, "Error during computation.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // ... +* +* // Free allocated memory: +* stdlib_ndarray_free( x ); +* stdlib_ndarray_free( mask ); +* stdlib_ndarray_free( y ); +*/ +int8_t stdlib_ndarray_mskfilter_{{SIGNATURE}}_8d( struct ndarray *arrays[] ) { + STDLIB_NDARRAY_mskfilter_8D_LOOP_{{LOOP_MACRO}}( {{LOOP_MACRO_ARGUMENTS}} ) + return 0; +} + +/** +* Applies a mask to a provided 8-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* ## Notes +* +* - If successful, the functions returns `0`; otherwise, the function returns an error code. +* +* @param arrays array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray and whose third element is a pointer to an output ndarray +* @return status code +* +* @example +* #include "stdlib/ndarray/base/mskfilter/{{SIGNATURE}}.h" +* #include "stdlib/ndarray/dtypes.h" +* #include "stdlib/ndarray/index_modes.h" +* #include "stdlib/ndarray/orders.h" +* #include "stdlib/ndarray/ctor.h"{{EXAMPLE_INCLUDES}} +* #include +* #include +* #include +* +* // Define the ndarray data types: +* enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_{{INPUT_NDARRAY_1_DTYPE_UPPER}}; +* enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +* enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_{{OUTPUT_NDARRAY_DTYPE_UPPER}}; +* +* // Create underlying byte arrays: +* uint8_t xbuf[] = { {{INPUT_NDARRAY_1_BYTES_8D}} }; +* uint8_t mbuf[] = { {{INPUT_NDARRAY_2_BYTES_8D}} }; +* uint8_t ybuf[] = { {{OUTPUT_NDARRAY_BYTES_8D}} }; +* +* // Define the number of dimensions: +* int64_t ndims = 8; +* +* // Define the array shapes: +* int64_t shx[] = { {{INPUT_NDARRAY_SHAPE_8D}} }; +* int64_t shm[] = { {{INPUT_NDARRAY_SHAPE_8D}} }; +* int64_t shy[] = { {{OUTPUT_NDARRAY_SHAPE_8D}} }; +* +* // Define the strides: +* int64_t sx[] = { {{INPUT_NDARRAY_1_STRIDES_8D}} }; +* int64_t sm[] = { {{INPUT_NDARRAY_2_STRIDES_8D}} }; +* int64_t sy[] = { {{OUTPUT_NDARRAY_STRIDES_8D}} }; +* +* // Define the offsets: +* int64_t ox = 0; +* int64_t om = 0; +* int64_t oy = 0; +* +* // Define the array order: +* enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; +* +* // Specify the index mode: +* enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; +* +* // Specify the subscript index modes: +* int8_t submodes[] = { imode }; +* int64_t nsubmodes = 1; +* +* // Create an input ndarray: +* struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes ); +* if ( x == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an mask ndarray: +* struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +* if ( mask == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an output ndarray: +* struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shape, sy, oy, order, imode, nsubmodes, submodes ); +* if ( y == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an array containing the ndarrays: +* struct ndarray *arrays[] = { x, mask, y }; +* +* // Copy elements: +* int8_t status = stdlib_ndarray_mskfilter_{{SIGNATURE}}_8d_blocked( arrays ); +* if ( status != 0 ) { +* fprintf( stderr, "Error during computation.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // ... +* +* // Free allocated memory: +* stdlib_ndarray_free( x ); +* stdlib_ndarray_free( mask ); +* stdlib_ndarray_free( y ); +*/ +int8_t stdlib_ndarray_mskfilter_{{SIGNATURE}}_8d_blocked( struct ndarray *arrays[] ) { + STDLIB_NDARRAY_mskfilter_8D_BLOCKED_LOOP_{{LOOP_MACRO}}( {{LOOP_MACRO_ARGUMENTS}} ) + return 0; +} + +/** +* Applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* ## Notes +* +* - If successful, the functions returns `0`; otherwise, the function returns an error code. +* +* @param arrays array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray and whose third element is a pointer to an output ndarray +* @return status code +* +* @example +* #include "stdlib/ndarray/base/mskfilter/{{SIGNATURE}}.h" +* #include "stdlib/ndarray/dtypes.h" +* #include "stdlib/ndarray/index_modes.h" +* #include "stdlib/ndarray/orders.h" +* #include "stdlib/ndarray/ctor.h"{{EXAMPLE_INCLUDES}} +* #include +* #include +* #include +* +* // Define the ndarray data types: +* enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_{{INPUT_NDARRAY_1_DTYPE_UPPER}}; +* enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +* enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_{{OUTPUT_NDARRAY_DTYPE_UPPER}}; +* +* // Create underlying byte arrays: +* uint8_t xbuf[] = { {{INPUT_NDARRAY_1_BYTES_9D}} }; +* uint8_t mbuf[] = { {{INPUT_NDARRAY_2_BYTES_9D}} }; +* uint8_t ybuf[] = { {{OUTPUT_NDARRAY_BYTES_9D}} }; +* +* // Define the number of dimensions: +* int64_t ndims = 9; +* +* // Define the array shapes: +* int64_t shx[] = { {{INPUT_NDARRAY_SHAPE_9D}} }; +* int64_t shm[] = { {{INPUT_NDARRAY_SHAPE_9D}} }; +* int64_t shy[] = { {{OUTPUT_NDARRAY_SHAPE_9D}} }; +* +* // Define the strides: +* int64_t sx[] = { {{INPUT_NDARRAY_1_STRIDES_9D}} }; +* int64_t sm[] = { {{INPUT_NDARRAY_2_STRIDES_9D}} }; +* int64_t sy[] = { {{OUTPUT_NDARRAY_STRIDES_9D}} }; +* +* // Define the offsets: +* int64_t ox = 0; +* int64_t om = 0; +* int64_t oy = 0; +* +* // Define the array order: +* enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; +* +* // Specify the index mode: +* enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; +* +* // Specify the subscript index modes: +* int8_t submodes[] = { imode }; +* int64_t nsubmodes = 1; +* +* // Create an input ndarray: +* struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes ); +* if ( x == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an mask ndarray: +* struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +* if ( mask == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an output ndarray: +* struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shape, sy, oy, order, imode, nsubmodes, submodes ); +* if ( y == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an array containing the ndarrays: +* struct ndarray *arrays[] = { x, mask, y }; +* +* // Copy elements: +* int8_t status = stdlib_ndarray_mskfilter_{{SIGNATURE}}_9d( arrays ); +* if ( status != 0 ) { +* fprintf( stderr, "Error during computation.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // ... +* +* // Free allocated memory: +* stdlib_ndarray_free( x ); +* stdlib_ndarray_free( mask ); +* stdlib_ndarray_free( y ); +*/ +int8_t stdlib_ndarray_mskfilter_{{SIGNATURE}}_9d( struct ndarray *arrays[] ) { + STDLIB_NDARRAY_mskfilter_9D_LOOP_{{LOOP_MACRO}}( {{LOOP_MACRO_ARGUMENTS}} ) + return 0; +} + +/** +* Applies a mask to a provided 9-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* ## Notes +* +* - If successful, the functions returns `0`; otherwise, the function returns an error code. +* +* @param arrays array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray and whose third element is a pointer to an output ndarray +* @return status code +* +* @example +* #include "stdlib/ndarray/base/mskfilter/{{SIGNATURE}}.h" +* #include "stdlib/ndarray/dtypes.h" +* #include "stdlib/ndarray/index_modes.h" +* #include "stdlib/ndarray/orders.h" +* #include "stdlib/ndarray/ctor.h"{{EXAMPLE_INCLUDES}} +* #include +* #include +* #include +* +* // Define the ndarray data types: +* enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_{{INPUT_NDARRAY_1_DTYPE_UPPER}}; +* enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +* enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_{{OUTPUT_NDARRAY_DTYPE_UPPER}}; +* +* // Create underlying byte arrays: +* uint8_t xbuf[] = { {{INPUT_NDARRAY_1_BYTES_9D}} }; +* uint8_t mbuf[] = { {{INPUT_NDARRAY_2_BYTES_9D}} }; +* uint8_t ybuf[] = { {{OUTPUT_NDARRAY_BYTES_9D}} }; +* +* // Define the number of dimensions: +* int64_t ndims = 9; +* +* // Define the array shapes: +* int64_t shx[] = { {{INPUT_NDARRAY_SHAPE_9D}} }; +* int64_t shm[] = { {{INPUT_NDARRAY_SHAPE_9D}} }; +* int64_t shy[] = { {{OUTPUT_NDARRAY_SHAPE_9D}} }; +* +* // Define the strides: +* int64_t sx[] = { {{INPUT_NDARRAY_1_STRIDES_9D}} }; +* int64_t sm[] = { {{INPUT_NDARRAY_2_STRIDES_9D}} }; +* int64_t sy[] = { {{OUTPUT_NDARRAY_STRIDES_9D}} }; +* +* // Define the offsets: +* int64_t ox = 0; +* int64_t om = 0; +* int64_t oy = 0; +* +* // Define the array order: +* enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; +* +* // Specify the index mode: +* enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; +* +* // Specify the subscript index modes: +* int8_t submodes[] = { imode }; +* int64_t nsubmodes = 1; +* +* // Create an input ndarray: +* struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes ); +* if ( x == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an mask ndarray: +* struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +* if ( mask == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an output ndarray: +* struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shape, sy, oy, order, imode, nsubmodes, submodes ); +* if ( y == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an array containing the ndarrays: +* struct ndarray *arrays[] = { x, mask, y }; +* +* // Copy elements: +* int8_t status = stdlib_ndarray_mskfilter_{{SIGNATURE}}_9d_blocked( arrays ); +* if ( status != 0 ) { +* fprintf( stderr, "Error during computation.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // ... +* +* // Free allocated memory: +* stdlib_ndarray_free( x ); +* stdlib_ndarray_free( mask ); +* stdlib_ndarray_free( y ); +*/ +int8_t stdlib_ndarray_mskfilter_{{SIGNATURE}}_9d_blocked( struct ndarray *arrays[] ) { + STDLIB_NDARRAY_mskfilter_9D_BLOCKED_LOOP_{{LOOP_MACRO}}( {{LOOP_MACRO_ARGUMENTS}} ) + return 0; +} + +/** +* Applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* ## Notes +* +* - If successful, the functions returns `0`; otherwise, the function returns an error code. +* +* @param arrays array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray and whose third element is a pointer to an output ndarray +* @return status code +* +* @example +* #include "stdlib/ndarray/base/mskfilter/{{SIGNATURE}}.h" +* #include "stdlib/ndarray/dtypes.h" +* #include "stdlib/ndarray/index_modes.h" +* #include "stdlib/ndarray/orders.h" +* #include "stdlib/ndarray/ctor.h"{{EXAMPLE_INCLUDES}} +* #include +* #include +* #include +* +* // Define the ndarray data types: +* enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_{{INPUT_NDARRAY_1_DTYPE_UPPER}}; +* enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +* enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_{{OUTPUT_NDARRAY_DTYPE_UPPER}}; +* +* // Create underlying byte arrays: +* uint8_t xbuf[] = { {{INPUT_NDARRAY_1_BYTES_10D}} }; +* uint8_t mbuf[] = { {{INPUT_NDARRAY_2_BYTES_10D}} }; +* uint8_t ybuf[] = { {{OUTPUT_NDARRAY_BYTES_10D}} }; +* +* // Define the number of dimensions: +* int64_t ndims = 10; +* +* // Define the array shapes: +* int64_t shx[] = { {{INPUT_NDARRAY_SHAPE_10D}} }; +* int64_t shm[] = { {{INPUT_NDARRAY_SHAPE_10D}} }; +* int64_t shy[] = { {{OUTPUT_NDARRAY_SHAPE_10D}} }; +* +* // Define the strides: +* int64_t sx[] = { {{INPUT_NDARRAY_1_STRIDES_10D}} }; +* int64_t sm[] = { {{INPUT_NDARRAY_2_STRIDES_10D}} }; +* int64_t sy[] = { {{OUTPUT_NDARRAY_STRIDES_10D}} }; +* +* // Define the offsets: +* int64_t ox = 0; +* int64_t om = 0; +* int64_t oy = 0; +* +* // Define the array order: +* enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; +* +* // Specify the index mode: +* enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; +* +* // Specify the subscript index modes: +* int8_t submodes[] = { imode }; +* int64_t nsubmodes = 1; +* +* // Create an input ndarray: +* struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes ); +* if ( x == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an mask ndarray: +* struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +* if ( mask == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an output ndarray: +* struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shape, sy, oy, order, imode, nsubmodes, submodes ); +* if ( y == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an array containing the ndarrays: +* struct ndarray *arrays[] = { x, mask, y }; +* +* // Copy elements: +* int8_t status = stdlib_ndarray_mskfilter_{{SIGNATURE}}_10d( arrays ); +* if ( status != 0 ) { +* fprintf( stderr, "Error during computation.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // ... +* +* // Free allocated memory: +* stdlib_ndarray_free( x ); +* stdlib_ndarray_free( mask ); +* stdlib_ndarray_free( y ); +*/ +int8_t stdlib_ndarray_mskfilter_{{SIGNATURE}}_10d( struct ndarray *arrays[] ) { + STDLIB_NDARRAY_mskfilter_10D_LOOP_{{LOOP_MACRO}}( {{LOOP_MACRO_ARGUMENTS}} ) + return 0; +} + +/** +* Applies a mask to a provided 10-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* ## Notes +* +* - If successful, the functions returns `0`; otherwise, the function returns an error code. +* +* @param arrays array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray and whose third element is a pointer to an output ndarray +* @return status code +* +* @example +* #include "stdlib/ndarray/base/mskfilter/{{SIGNATURE}}.h" +* #include "stdlib/ndarray/dtypes.h" +* #include "stdlib/ndarray/index_modes.h" +* #include "stdlib/ndarray/orders.h" +* #include "stdlib/ndarray/ctor.h"{{EXAMPLE_INCLUDES}} +* #include +* #include +* #include +* +* // Define the ndarray data types: +* enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_{{INPUT_NDARRAY_1_DTYPE_UPPER}}; +* enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +* enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_{{OUTPUT_NDARRAY_DTYPE_UPPER}}; +* +* // Create underlying byte arrays: +* uint8_t xbuf[] = { {{INPUT_NDARRAY_1_BYTES_10D}} }; +* uint8_t mbuf[] = { {{INPUT_NDARRAY_2_BYTES_10D}} }; +* uint8_t ybuf[] = { {{OUTPUT_NDARRAY_BYTES_10D}} }; +* +* // Define the number of dimensions: +* int64_t ndims = 10; +* +* // Define the array shapes: +* int64_t shx[] = { {{INPUT_NDARRAY_SHAPE_10D}} }; +* int64_t shm[] = { {{INPUT_NDARRAY_SHAPE_10D}} }; +* int64_t shy[] = { {{OUTPUT_NDARRAY_SHAPE_10D}} }; +* +* // Define the strides: +* int64_t sx[] = { {{INPUT_NDARRAY_1_STRIDES_10D}} }; +* int64_t sm[] = { {{INPUT_NDARRAY_2_STRIDES_10D}} }; +* int64_t sy[] = { {{OUTPUT_NDARRAY_STRIDES_10D}} }; +* +* // Define the offsets: +* int64_t ox = 0; +* int64_t om = 0; +* int64_t oy = 0; +* +* // Define the array order: +* enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; +* +* // Specify the index mode: +* enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; +* +* // Specify the subscript index modes: +* int8_t submodes[] = { imode }; +* int64_t nsubmodes = 1; +* +* // Create an input ndarray: +* struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes ); +* if ( x == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an mask ndarray: +* struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +* if ( mask == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an output ndarray: +* struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shape, sy, oy, order, imode, nsubmodes, submodes ); +* if ( y == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an array containing the ndarrays: +* struct ndarray *arrays[] = { x, mask, y }; +* +* // Copy elements: +* int8_t status = stdlib_ndarray_mskfilter_{{SIGNATURE}}_10d_blocked( arrays ); +* if ( status != 0 ) { +* fprintf( stderr, "Error during computation.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // ... +* +* // Free allocated memory: +* stdlib_ndarray_free( x ); +* stdlib_ndarray_free( mask ); +* stdlib_ndarray_free( y ); +*/ +int8_t stdlib_ndarray_mskfilter_{{SIGNATURE}}_10d_blocked( struct ndarray *arrays[] ) { + STDLIB_NDARRAY_mskfilter_10D_BLOCKED_LOOP_{{LOOP_MACRO}}( {{LOOP_MACRO_ARGUMENTS}} ) + return 0; +} + +/** +* Applies a mask to a provided n-dimensional input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* ## Notes +* +* - If successful, the functions returns `0`; otherwise, the function returns an error code. +* +* @param arrays array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray and whose third element is a pointer to an output ndarray +* @return status code +* +* @example +* #include "stdlib/ndarray/base/mskfilter/{{SIGNATURE}}.h" +* #include "stdlib/ndarray/dtypes.h" +* #include "stdlib/ndarray/index_modes.h" +* #include "stdlib/ndarray/orders.h" +* #include "stdlib/ndarray/ctor.h"{{EXAMPLE_INCLUDES}} +* #include +* #include +* #include +* +* // Define the ndarray data types: +* enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_{{INPUT_NDARRAY_1_DTYPE_UPPER}}; +* enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +* enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_{{OUTPUT_NDARRAY_DTYPE_UPPER}}; +* +* // Create underlying byte arrays: +* uint8_t xbuf[] = { {{INPUT_NDARRAY_1_BYTES_3D}} }; +* uint8_t mbuf[] = { {{INPUT_NDARRAY_2_BYTES_3D}} }; +* uint8_t ybuf[] = { {{OUTPUT_NDARRAY_BYTES_3D}} }; +* +* // Define the number of dimensions: +* int64_t ndims = 3; +* +* // Define the array shapes: +* int64_t shx[] = { {{INPUT_NDARRAY_SHAPE_3D}} }; +* int64_t shm[] = { {{INPUT_NDARRAY_SHAPE_3D}} }; +* int64_t shy[] = { {{OUTPUT_NDARRAY_SHAPE_3D}} }; +* +* // Define the strides: +* int64_t sx[] = { {{INPUT_NDARRAY_1_STRIDES_3D}} }; +* int64_t sm[] = { {{INPUT_NDARRAY_2_STRIDES_3D}} }; +* int64_t sy[] = { {{OUTPUT_NDARRAY_STRIDES_3D}} }; +* +* // Define the offsets: +* int64_t ox = 0; +* int64_t om = 0; +* int64_t oy = 0; +* +* // Define the array order: +* enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; +* +* // Specify the index mode: +* enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; +* +* // Specify the subscript index modes: +* int8_t submodes[] = { imode }; +* int64_t nsubmodes = 1; +* +* // Create an input ndarray: +* struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes ); +* if ( x == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an mask ndarray: +* struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +* if ( mask == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an output ndarray: +* struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shape, sy, oy, order, imode, nsubmodes, submodes ); +* if ( y == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an array containing the ndarrays: +* struct ndarray *arrays[] = { x, mask, y }; +* +* // Copy elements: +* int8_t status = stdlib_ndarray_mskfilter_{{SIGNATURE}}_nd( arrays ); +* if ( status != 0 ) { +* fprintf( stderr, "Error during computation.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // ... +* +* // Free allocated memory: +* stdlib_ndarray_free( x ); +* stdlib_ndarray_free( mask ); +* stdlib_ndarray_free( y ); +*/ +int8_t stdlib_ndarray_mskfilter_{{SIGNATURE}}_nd( struct ndarray *arrays[] ) { + STDLIB_NDARRAY_mskfilter_ND_LOOP_{{LOOP_MACRO}}( {{LOOP_MACRO_ARGUMENTS}} ) + return 0; +} + +// Define a list of unary ndarray functions: +static ndarrayUnarymskfilterFcn functions[] = { + stdlib_ndarray_mskfilter_{{SIGNATURE}}_0d, + stdlib_ndarray_mskfilter_{{SIGNATURE}}_1d, + stdlib_ndarray_mskfilter_{{SIGNATURE}}_2d, + stdlib_ndarray_mskfilter_{{SIGNATURE}}_3d, + stdlib_ndarray_mskfilter_{{SIGNATURE}}_4d, + stdlib_ndarray_mskfilter_{{SIGNATURE}}_5d, + stdlib_ndarray_mskfilter_{{SIGNATURE}}_6d, + stdlib_ndarray_mskfilter_{{SIGNATURE}}_7d, + stdlib_ndarray_mskfilter_{{SIGNATURE}}_8d, + stdlib_ndarray_mskfilter_{{SIGNATURE}}_9d, + stdlib_ndarray_mskfilter_{{SIGNATURE}}_10d, + stdlib_ndarray_mskfilter_{{SIGNATURE}}_nd +}; + +// Define a list of unary ndarray functions implementing loop blocking... +static ndarrayUnarymskfilterFcn blocked_functions[] = { + stdlib_ndarray_mskfilter_{{SIGNATURE}}_2d_blocked, + stdlib_ndarray_mskfilter_{{SIGNATURE}}_3d_blocked, + stdlib_ndarray_mskfilter_{{SIGNATURE}}_4d_blocked, + stdlib_ndarray_mskfilter_{{SIGNATURE}}_5d_blocked, + stdlib_ndarray_mskfilter_{{SIGNATURE}}_6d_blocked, + stdlib_ndarray_mskfilter_{{SIGNATURE}}_7d_blocked, + stdlib_ndarray_mskfilter_{{SIGNATURE}}_8d_blocked, + stdlib_ndarray_mskfilter_{{SIGNATURE}}_9d_blocked, + stdlib_ndarray_mskfilter_{{SIGNATURE}}_10d_blocked +}; + +// Create a unary function dispatch object: +static const struct ndarrayUnarymskfilterDispatchObject obj = { + // Array containing unary ndarray functions: + functions, + + // Number of unary ndarray functions: + 12, + + // Array containing unary ndarray functions using loop blocking: + blocked_functions, + + // Number of unary ndarray functions using loop blocking: + 9 +}; + +/** +* Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. +* +* ## Notes +* +* - If successful, the functions returns `0`; otherwise, the function returns an error code. +* +* @param arrays array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray and whose third element is a pointer to an output ndarray +* @return status code +* +* @example +* #include "stdlib/ndarray/base/mskfilter/{{SIGNATURE}}.h" +* #include "stdlib/ndarray/dtypes.h" +* #include "stdlib/ndarray/index_modes.h" +* #include "stdlib/ndarray/orders.h" +* #include "stdlib/ndarray/ctor.h"{{EXAMPLE_INCLUDES}} +* #include +* #include +* #include +* +* // Define the ndarray data types: +* enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_{{INPUT_NDARRAY_1_DTYPE_UPPER}}; +* enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +* enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_{{OUTPUT_NDARRAY_DTYPE_UPPER}}; +* +* // Create underlying byte arrays: +* uint8_t xbuf[] = { {{INPUT_NDARRAY_1_BYTES_2D}} }; +* uint8_t mbuf[] = { {{INPUT_NDARRAY_2_BYTES_2D}} }; +* uint8_t ybuf[] = { {{OUTPUT_NDARRAY_BYTES_2D}} }; +* +* // Define the number of dimensions: +* int64_t ndims = 2; +* +* // Define the array shapes: +* int64_t shx[] = { {{INPUT_NDARRAY_SHAPE_2D}} }; +* int64_t shm[] = { {{INPUT_NDARRAY_SHAPE_2D}} }; +* int64_t shy[] = { {{OUTPUT_NDARRAY_SHAPE_2D}} }; +* +* // Define the strides: +* int64_t sx[] = { {{INPUT_NDARRAY_1_STRIDES_2D}} }; +* int64_t sm[] = { {{INPUT_NDARRAY_2_STRIDES_2D}} }; +* int64_t sy[] = { {{OUTPUT_NDARRAY_STRIDES_2D}} }; +* +* // Define the offsets: +* int64_t ox = 0; +* int64_t om = 0; +* int64_t oy = 0; +* +* // Define the array order: +* enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; +* +* // Specify the index mode: +* enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; +* +* // Specify the subscript index modes: +* int8_t submodes[] = { imode }; +* int64_t nsubmodes = 1; +* +* // Create an input ndarray: +* struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes ); +* if ( x == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an mask ndarray: +* struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +* if ( mask == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an output ndarray: +* struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shape, sy, oy, order, imode, nsubmodes, submodes ); +* if ( y == NULL ) { +* fprintf( stderr, "Error allocating memory.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // Create an array containing the ndarrays: +* struct ndarray *arrays[] = { x, mask, y }; +* +* // Copy elements: +* int8_t status = stdlib_ndarray_mskfilter_{{SIGNATURE}}( arrays ); +* if ( status != 0 ) { +* fprintf( stderr, "Error during computation.\n" ); +* exit( EXIT_FAILURE ); +* } +* +* // ... +* +* // Free allocated memory: +* stdlib_ndarray_free( x ); +* stdlib_ndarray_free( mask ); +* stdlib_ndarray_free( y ); +*/ +int8_t stdlib_ndarray_mskfilter_{{SIGNATURE}}( struct ndarray *arrays[] ) { + return stdlib_ndarray_unary_mskfilter_dispatch( &obj, arrays ); +} From 9c1003c366ba1b579eeaf59624715e5880a4b329 Mon Sep 17 00:00:00 2001 From: Jaysukh-409 Date: Mon, 16 Sep 2024 17:46:33 +0530 Subject: [PATCH 31/34] feat: update scripts and templates --- .../stdlib/ndarray/base/mskfilter/typedefs.h | 38 + .../ndarray/base/mskfilter/manifest.json | 100 +++ .../ndarray/base/mskfilter/scripts/loops.js | 842 ++++++++++++++++++ .../base/mskfilter/scripts/templates/docs.txt | 2 +- .../mskfilter/scripts/templates/source.txt | 6 +- 5 files changed, 984 insertions(+), 4 deletions(-) create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/typedefs.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/scripts/loops.js diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/typedefs.h b/lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/typedefs.h new file mode 100644 index 00000000000..626e1d3b210 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/typedefs.h @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#ifndef STDLIB_NDARRAY_BASE_MSKFILTER_TYPEDEFS_H +#define STDLIB_NDARRAY_BASE_MSKFILTER_TYPEDEFS_H + +#include "stdlib/ndarray/ctor.h" +#include + +/** +* Function pointer type for a unary ndarray function. +* +* ## Note +* +* - This must match the definition of an `ndarrayFcn` found in `@stdlib/ndarray/base/function-object`. +* +* @param arrays array containing pointers to input and output ndarrays +* @param data function "data" (e.g., a callback) +* @return status code +*/ +typedef int8_t (*ndarrayUnaryMskfilterFcn)( struct ndarray *arrays[], void *data ); + +#endif // !STDLIB_NDARRAY_BASE_MSKFILTER_TYPEDEFS_H diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/manifest.json b/lib/node_modules/@stdlib/ndarray/base/mskfilter/manifest.json index e69de29bb2d..20bbf536535 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/manifest.json +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/manifest.json @@ -0,0 +1,100 @@ +{ + "options": {}, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "src": [ + "./src/b_b.c", + "./src/b_c.c", + "./src/b_d.c", + "./src/b_f.c", + "./src/b_i.c", + "./src/b_k.c", + "./src/b_t.c", + "./src/b_u.c", + "./src/b_z.c", + "./src/c_c.c", + "./src/c_z.c", + "./src/d_c.c", + "./src/d_d.c", + "./src/d_f.c", + "./src/d_z.c", + "./src/f_c.c", + "./src/f_d.c", + "./src/f_f.c", + "./src/f_z.c", + "./src/i_d.c", + "./src/i_i.c", + "./src/i_u.c", + "./src/i_z.c", + "./src/k_c.c", + "./src/k_d.c", + "./src/k_f.c", + "./src/k_i.c", + "./src/k_k.c", + "./src/k_t.c", + "./src/k_u.c", + "./src/k_z.c", + "./src/s_b.c", + "./src/s_c.c", + "./src/s_d.c", + "./src/s_f.c", + "./src/s_i.c", + "./src/s_k.c", + "./src/s_s.c", + "./src/s_t.c", + "./src/s_u.c", + "./src/s_z.c", + "./src/t_c.c", + "./src/t_d.c", + "./src/t_f.c", + "./src/t_i.c", + "./src/t_t.c", + "./src/t_u.c", + "./src/t_z.c", + "./src/u_d.c", + "./src/u_u.c", + "./src/u_z.c", + "./src/x_x.c", + "./src/z_c.c", + "./src/z_z.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/complex/float32/ctor", + "@stdlib/complex/float64/ctor", + "@stdlib/ndarray/base/bytes-per-element", + "@stdlib/ndarray/base/iteration-order", + "@stdlib/ndarray/base/vind2bind", + "@stdlib/ndarray/ctor", + "@stdlib/ndarray/index-modes", + "@stdlib/ndarray/orders" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/scripts/loops.js b/lib/node_modules/@stdlib/ndarray/base/mskfilter/scripts/loops.js new file mode 100644 index 00000000000..5de7c525245 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/scripts/loops.js @@ -0,0 +1,842 @@ +#!/usr/bin/env node + +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-lines, @cspell/spellchecker */ + +'use strict'; + +// MODULES // + +var path = require( 'path' ); +var logger = require( 'debug' ); +var readDir = require( '@stdlib/fs/read-dir' ).sync; +var unlink = require( '@stdlib/fs/unlink' ).sync; +var readFile = require( '@stdlib/fs/read-file' ).sync; +var readJSON = require( '@stdlib/fs/read-json' ).sync; +var writeFile = require( '@stdlib/fs/write-file' ).sync; +var replace = require( '@stdlib/string/replace' ); +var substringBefore = require( '@stdlib/string/substring-before' ); +var substringAfter = require( '@stdlib/string/substring-after' ); +var uppercase = require( '@stdlib/string/uppercase' ); +var dtypes = require( '@stdlib/ndarray/dtypes' ); +var mostlySafeCasts = require( '@stdlib/ndarray/mostly-safe-casts' ); +var dtypeChar = require( '@stdlib/ndarray/base/dtype-char' ); +var dtypeDesc = require( '@stdlib/ndarray/base/dtype-desc' ); +var dtype2c = require( '@stdlib/ndarray/base/dtype2c' ); +var char2dtype = require( '@stdlib/ndarray/base/char2dtype' ); +var bytesPerElement = require( '@stdlib/ndarray/base/bytes-per-element' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var gscal = require( '@stdlib/blas/base/gscal' ); +var filledarray = require( '@stdlib/array/filled' ); +var currentYear = require( '@stdlib/time/current-year' ); +var format = require( '@stdlib/string/format' ); + + +// VARIABLES // + +var FOPTS = { + 'encoding': 'utf8' +}; + +// Logger: +var debug = logger( 'ndarray-mskfilter-loops:script' ); + +// Get the current year: +var CURRENT_YEAR = currentYear().toString(); + +// Specify the copyright holder: +var COPYRIGHT = 'The Stdlib Authors'; + +// Templates: +var TMPL_HEADER = readFile( path.join( __dirname, 'templates', 'header.txt' ), FOPTS ); +var TMPL_SOURCE = readFile( path.join( __dirname, 'templates', 'source.txt' ), FOPTS ); +var TMPL_README = readFile( path.join( __dirname, 'templates', 'docs.txt' ), FOPTS ); + +// Output directories: +var INCLUDE_DIR = path.resolve( __dirname, '..', 'include', 'stdlib', 'ndarray', 'base', 'mskfilter' ); +var SRC_DIR = path.resolve( __dirname, '..', 'src' ); + +// Main header file: +var INCLUDE_MAIN = INCLUDE_DIR + '.h'; + +// Manifest file: +var MANIFEST = path.resolve( __dirname, '..', 'manifest.json' ); + +// README file: +var README = path.resolve( __dirname, '..', 'README.md' ); + +// Data types to exclude when generating loops: +var EXCLUDE_DTYPES = [ 'binary', 'generic', 'uint8c' ]; + +// Resolve a list of dtypes for which we want to create loops: +var DTYPES = filter( dtypes(), EXCLUDE_DTYPES ); + +// Define "special" loops, which cannot be readily generated according to standardized rules: +var SPECIAL_LOOPS = [ + // Support callbacks which operate on signed integers, but whose return values are always positive and can be cast to unsigned integers of the same or greater bit width: + 'i_u', + 'k_t', + 'k_u', + 's_b', + 's_t', + 's_u' +]; + +// Hash containing C macro names: +var MACROS = { + 'nocast': 'NOCAST', + 'cast': 'CAST', + 'fcast': 'CAST_FCN' +}; + +// Regular expression to test for a "loop" file: +var RE_LOOP_FILE = /^[a-z]_[a-z]\.(?:h|c)$/; + +// Regular expression to test for a "loop" file in the manifest.json: +var RE_MANIFEST_LOOP_FILE = /\.\/src\/[a-z]_[a-z]\.c$/; + +// Regular expression to match input and output array dtype characters: +var RE_SIGNATURE = /^([a-z])_([a-z])/; + +// Specify array INPUT_SHAPES: +var INPUT_SHAPES = [ + [], + [ 3 ], + [ 2, 2 ], + [ 2, 2, 2 ], + [ 1, 2, 2, 2 ], + [ 1, 1, 2, 2, 2 ], + [ 1, 1, 1, 2, 2, 2 ], + [ 1, 1, 1, 1, 2, 2, 2 ], + [ 1, 1, 1, 1, 1, 2, 2, 2 ], + [ 1, 1, 1, 1, 1, 1, 2, 2, 2 ], + [ 1, 1, 1, 1, 1, 1, 1, 2, 2, 2 ] +]; + +var OUTPUT_SHAPES = [ + [], + [ 3 ], + [ 4 ], + [ 8 ], + [ 8 ], + [ 8 ], + [ 8 ], + [ 8 ], + [ 8 ], + [ 8 ], + [ 8 ] +]; + +// Array order: +var ORDER = 'row-major'; + + +// FUNCTIONS // + +/** +* Removes a list of elements from a provided list. +* +* @private +* @param {ArrayLikeObject} src - list to filter +* @param {ArrayLikeObject} list - items to remove +* @returns {Array} filtered list +* +* @example +* var src = [ 'a', 'b', 'c', 'd' ]; +* var list = [ 'b', 'd' ]; +* +* var out = filter( src, list ); +* // returns [ 'a', 'c' ] +*/ +function filter( src, list ) { + var out; + var M; + var N; + var v; + var i; + var j; + + M = src.length; + N = list.length; + + out = []; + for ( i = 0; i < M; i++ ) { + v = src[ i ]; + for ( j = 0; j < N; j++ ) { + if ( v === list[ j ] ) { + break; + } + } + if ( j === N ) { + out.push( v ); + } + } + return out; +} + +/** +* Removes loop files from a directory. +* +* @private +* @param {string} dir - directory +*/ +function removeLoopFiles( dir ) { + var list; + var i; + + list = readDir( dir ); + for ( i = 0; i < list.length; i++ ) { + if ( RE_LOOP_FILE.test( list[ i ] ) ) { + unlink( path.join( dir, list[ i ] ) ); + } + } +} + +/** +* Generates a list of loop signatures from a list of data types. +* +* @private +* @param {StringArray} dtypes - list of data types +* @returns {StringArray} list of loop signatures +*/ +function signatures( dtypes ) { + var casts; + var out; + var ch1; + var ch2; + var t1; + var t2; + var N; + var s; + var i; + var j; + + N = dtypes.length; + + // Generate the list of signatures: + out = []; + for ( i = 0; i < N; i++ ) { + t1 = dtypes[ i ]; + + // Resolve single-letter dtype abbreviation: + ch1 = dtypeChar( t1 ); + + // Generate the input/output array signature: + s = ch1+'_'+ch1; // e.g., d_d + out.push( s ); + + // Resolve the list of (mostly) safe casts for the input dtype: + casts = mostlySafeCasts( t1 ); + + // Remove the excluded dtypes: + casts = filter( casts, EXCLUDE_DTYPES ); + + // Generate signatures for allowed casts: + for ( j = 0; j < casts.length; j++ ) { + t2 = casts[ j ]; + if ( t2 === t1 ) { + continue; + } + ch2 = dtypeChar( t2 ); + s = ch1+'_'+ch2; + + out.push( s ); // e.g., `b_i` + } + } + // Append any special loops: + for ( i = 0; i < SPECIAL_LOOPS.length; i++ ) { + out.push( SPECIAL_LOOPS[ i ] ); + } + return out.sort(); +} + +/** +* Defines byte arrays in a provided template string. +* +* @private +* @param {string} tmpl - template string +* @param {PositiveInteger} nb1 - bytes per element for input array +* @param {PositiveInteger} nb2 - bytes per element for mask array +* @param {PositiveInteger} nb3 - bytes per element for output array +* @returns {string} updated string +*/ +function defineByteArrays( tmpl, nb1, nb2, nb3 ) { + var bytes; + var tmp; + var N; + var i; + + bytes = filledarray( 0, nb1, 'generic' ).join( ', ' ); + tmpl = replace( tmpl, '{{INPUT_NDARRAY_1_BYTES_0D}}', bytes ); + + bytes = filledarray( 0, nb2, 'generic' ).join( ', ' ); + tmpl = replace( tmpl, '{{INPUT_NDARRAY_2_BYTES_0D}}', bytes ); + + bytes = filledarray( 0, nb3, 'generic' ).join( ', ' ); + tmpl = replace( tmpl, '{{OUTPUT_NDARRAY_BYTES_0D}}', bytes ); + + for ( i = 1; i < INPUT_SHAPES.length; i++ ) { + N = numel( INPUT_SHAPES[ i ] ); + + tmp = '{{INPUT_NDARRAY_1_BYTES_'+i+'D}}'; + bytes = filledarray( 0, nb1*N, 'generic' ).join( ', ' ); + tmpl = replace( tmpl, tmp, bytes ); + + tmp = '{{INPUT_NDARRAY_2_BYTES_'+i+'D}}'; + bytes = filledarray( 0, nb2*N, 'generic' ).join( ', ' ); + tmpl = replace( tmpl, tmp, bytes ); + + tmp = '{{OUTPUT_NDARRAY_BYTES_'+i+'D}}'; + bytes = filledarray( 0, nb3*N, 'generic' ).join( ', ' ); + tmpl = replace( tmpl, tmp, bytes ); + } + return tmpl; +} + +/** +* Defines array strides in a provided template string. +* +* @private +* @param {string} tmpl - template string +* @param {PositiveInteger} nb1 - bytes per element for input array +* @param {PositiveInteger} nb2 - bytes per element for mask array +* @param {PositiveInteger} nb3 - bytes per element for output array +* @returns {string} updated string +*/ +function defineStrides( tmpl, nb1, nb2, nb3 ) { + var strides; + var tmp; + var st; + var i; + + for ( i = 1; i < INPUT_SHAPES.length; i++ ) { + strides = shape2strides( INPUT_SHAPES[ i ], ORDER ); + + tmp = '{{INPUT_NDARRAY_1_STRIDES_'+i+'D}}'; + st = gscal( strides.length, nb1, strides.slice(), 1 ); + tmpl = replace( tmpl, tmp, st.join( ', ' ) ); + + tmp = '{{INPUT_NDARRAY_2_STRIDES_'+i+'D}}'; + st = gscal( strides.length, nb2, strides.slice(), 1 ); + tmpl = replace( tmpl, tmp, st.join( ', ' ) ); + + strides = shape2strides( OUTPUT_SHAPES[ i ], ORDER ); + + tmp = '{{OUTPUT_NDARRAY_STRIDES_'+i+'D}}'; + st = gscal( strides.length, nb3, strides.slice(), 1 ); + tmpl = replace( tmpl, tmp, st.join( ', ' ) ); + } + return tmpl; +} + +/** +* Defines array INPUT_SHAPES in a provided template string. +* +* @private +* @param {string} tmpl - template string +* @returns {string} updated string +*/ +function defineShapes( tmpl ) { + var i; + for ( i = 1; i < INPUT_SHAPES.length; i++ ) { + tmpl = replace( tmpl, '{{INPUT_NDARRAY_SHAPE_'+i+'D}}', INPUT_SHAPES[ i ].join( ', ' ) ); + tmpl = replace( tmpl, '{{OUTPUT_NDARRAY_SHAPE_'+i+'D}}', OUTPUT_SHAPES[ i ].join( ', ' ) ); + } + return tmpl; +} + +/** +* Creates a header file for a provided loop signature. +* +* @private +* @param {string} signature - loop signature +* @throws {Error} unexpected error +*/ +function createHeaderFile( signature ) { + var fpath; + var file; + var err; + + file = replace( TMPL_HEADER, '{{YEAR}}', CURRENT_YEAR ); + file = replace( file, '{{COPYRIGHT}}', COPYRIGHT ); + file = replace( file, '{{INCLUDE_GUARD}}', uppercase( signature ) ); + file = replace( file, '{{SIGNATURE}}', signature ); + + fpath = path.join( INCLUDE_DIR, signature+'.h' ); + + debug( 'Creating header file: %s', fpath ); + err = writeFile( fpath, file, FOPTS ); + if ( err ) { + throw err; + } +} + +/** +* Creates header files for a list of loop signatures. +* +* @private +* @param {StringArray} signatures - list of loop signatures +*/ +function createHeaderFiles( signatures ) { + var i; + for ( i = 0; i < signatures.length; i++ ) { + createHeaderFile( signatures[ i ] ); + } +} + +/** +* Creates a source file for a provided loop signature. +* +* @private +* @param {string} signature - loop signature +* @throws {Error} unexpected error +*/ +function createSourceFile( signature ) { + var match1; + var macro; + var fpath; + var file; + var args; + var err; + var inc; + var tmp; + var ch1; + var ch2; + var ct1; + var ct2; + var nb1; + var nb2; + var nb3; + var t1; + var t2; + var t3; + + file = replace( TMPL_SOURCE, '{{YEAR}}', CURRENT_YEAR ); + file = replace( file, '{{COPYRIGHT}}', COPYRIGHT ); + file = replace( file, '{{SIGNATURE}}', signature ); + + // Ensure the appropriate header files are included in source files: + inc = []; + if ( /c/.test( signature ) ) { + inc.push( '#include "stdlib/complex/float32/ctor.h"' ); + } + if ( /z/.test( signature ) ) { + inc.push( '#include "stdlib/complex/float64/ctor.h"' ); + } + if ( /x/.test( signature ) ) { + inc.push( '#include ' ); + } + if ( inc.length ) { + file = replace( file, '{{INCLUDES}}', '\n'+inc.join( '\n' ) ); + } else { + file = replace( file, '{{INCLUDES}}', '' ); + } + // Ensure the appropriate header files are included in source documentation examples: + file = replace( file, '{{EXAMPLE_INCLUDES}}', '' ); + + // Resolve the array data types: + match1 = signature.match( RE_SIGNATURE ); + t2 = 'uint8'; + ch1 = match1[ 1 ]; + t1 = char2dtype( ch1 ); + ch2 = match1[ 2 ]; + t3 = char2dtype( ch2 ); + + // Define array data types: + file = replace( file, '{{INPUT_NDARRAY_1_DTYPE_UPPER}}', uppercase( t1 ) ); + file = replace( file, '{{OUTPUT_NDARRAY_DTYPE_UPPER}}', uppercase( t3 ) ); + + file = replace( file, '{{INPUT_NDARRAY_1_DTYPE_LOWER}}', t1 ); + file = replace( file, '{{OUTPUT_NDARRAY_DTYPE_LOWER}}', t3 ); + + // Define the number of bytes per element for the respective arrays: + nb1 = bytesPerElement( t1 ); + file = replace( file, '{{INPUT_NDARRAY_1_BYTES_PER_ELEMENT}}', nb1.toString() ); + + nb2 = bytesPerElement( t2 ); + file = replace( file, '{{INPUT_NDARRAY_2_BYTES_PER_ELEMENT}}', nb2.toString() ); + + nb3 = bytesPerElement( t3 ); + file = replace( file, '{{OUTPUT_NDARRAY_BYTES_PER_ELEMENT}}', nb3.toString() ); + + // Define the array INPUT_SHAPES: + file = defineShapes( file ); + + // Define underlying byte arrays: + file = defineByteArrays( file, nb1, nb2, nb3 ); + + // Define array strides: + file = defineStrides( file, nb1, nb2, nb3 ); + + // Resolve C data types: + ct1 = dtype2c( t1 ); + ct2 = dtype2c( t3 ); + + // Resolve the 0D expression: + if ( /[cz]/.test( signature ) ) { + if ( ch1 === ch2 ) { // e.g., z_z, c_c + tmp = 'v'; + } else if ( ch2 === 'z' ) { // e.g., c_z, d_z, u_z + tmp = format( 'stdlib_complex128_from_%s( v )', char2dtype( ch1 ) );// e.g., stdlib_complex128_from_float64( v ) + } else if ( ch2 === 'c' ) { + if ( ch1 === 'z' ) { // e.g., z_c + tmp = 'stdlib_complex128_to_complex64( v )'; + } else { // e.g., f_c + tmp = format( 'stdlib_complex64_from_%s( v )', char2dtype( ch1 ) ); + } + } else { // e.g., z_d, c_f + // Based on type promotion rules and conventions, we shouldn't reach here. + } + } else if ( ch1 === ch2 ) { // e.g., d_d, f_f, b_b + tmp = 'v'; + } else { // e.g., b_d, f_d + tmp = format( '(%s)v', ct2 ); // e.g., (double)v + } + file = replace( file, '{{EXPRESSION_0D}}', tmp ); + + // Resolve the loop macro: + if ( /[cz]/.test( signature ) ) { + // E.g., z_z, c_c, c_z, f_c, d_z, u_z, #_(c|z), etc. + if ( ch1 === ch2 ) { // e.g., z_z, c_c + macro = MACROS.nocast; + args = [ ct1, ct2 ]; + } else if ( ch2 === 'z' ) { // e.g., c_z, d_z, u_z + macro = MACROS.fcast; + args = [ ct1, ct2, 'stdlib_complex128_from_'+char2dtype( ch1 ) ]; + } else if ( ch2 === 'c' ) { + macro = MACROS.fcast; + args = [ ct1, ct2 ]; + if ( ch1 === 'z' ) { // e.g., z_c + args.push( 'stdlib_complex128_to_complex64' ); + } else { // e.g., f_c + args.push( 'stdlib_complex64_from_'+char2dtype( ch1 ) ); + } + } else { // e.g., z_d + throw new Error( 'unexpected error. Should not reach this branch according to type promotion rules.' ); + } + } else { + macro = MACROS.cast; + args = [ ct1, ct2 ]; + } + file = replace( file, '{{LOOP_MACRO}}', macro ); + file = replace( file, '{{LOOP_MACRO_ARGUMENTS}}', args.join( ', ' ) ); + + // Create the source file: + fpath = path.join( SRC_DIR, signature+'.c' ); + debug( 'Creating source file: %s', fpath ); + err = writeFile( fpath, file, FOPTS ); + if ( err ) { + throw err; + } +} + +/** +* Creates source files for a list of loop signatures. +* +* @private +* @param {StringArray} signatures - list of loop signatures +*/ +function createSourceFiles( signatures ) { + var i; + for ( i = 0; i < signatures.length; i++ ) { + createSourceFile( signatures[ i ] ); + } +} + +/** +* Generates README documentation for a loop interface. +* +* @private +* @param {string} signature - loop signature +* @returns {string} documentation +*/ +function createDoc( signature ) { + var match; + var doc; + var ch1; + var ch2; + var nb1; + var nb2; + var nb3; + var t1; + var t2; + var t3; + + doc = replace( TMPL_README, '{{SIGNATURE}}', signature ); + + // Ensure appropriate header files are included in documentation examples: + doc = replace( doc, '{{EXAMPLE_INCLUDES}}', '' ); + + // Resolve the array data types: + match = signature.match( RE_SIGNATURE ); + t2 = 'uint8'; + ch1 = match[ 1 ]; + t1 = char2dtype( ch1 ); + ch2 = match[ 2 ]; + t3 = char2dtype( ch2 ); + + // Define array data types: + doc = replace( doc, '{{INPUT_NDARRAY_1_DTYPE_UPPER}}', uppercase( t1 ) ); + doc = replace( doc, '{{OUTPUT_NDARRAY_DTYPE_UPPER}}', uppercase( t3 ) ); + + // Define the number of bytes per element for the respective arrays: + nb1 = bytesPerElement( t1 ); + doc = replace( doc, '{{INPUT_NDARRAY_1_BYTES_PER_ELEMENT}}', nb1.toString() ); + + nb2 = bytesPerElement( t2 ); + doc = replace( doc, '{{INPUT_NDARRAY_2_BYTES_PER_ELEMENT}}', nb2.toString() ); + + nb3 = bytesPerElement( t3 ); + doc = replace( doc, '{{OUTPUT_NDARRAY_BYTES_PER_ELEMENT}}', nb3.toString() ); + + // Define the array INPUT_SHAPES: + doc = defineShapes( doc ); + + // Define underlying byte arrays: + doc = defineByteArrays( doc, nb1, nb2, nb3 ); + + // Define array strides: + doc = defineStrides( doc, nb1, nb2, nb3 ); + + return doc; +} + +/** +* Returns a character code list item. +* +* @private +* @param {string} dtype - data type +* @returns {string} list item +*/ +function charCodeListItem( dtype ) { + return [ + '- **', + dtypeChar( dtype ), + '**: `', + dtype, + '` (', + dtypeDesc( dtype ), + ').' + ].join( '' ); +} + +/** +* Returns a list of character code descriptions. +* +* @private +* @param {StringArray} dtypes - list of data types +* @returns {StringArray} list of character code descriptions +*/ +function charCodeList( dtypes ) { + var out; + var i; + + out = []; + for ( i = 0; i < dtypes.length; i++ ) { + out.push( charCodeListItem( dtypes[ i ] ) ); + } + return out; +} + +/** +* Update the package README. +* +* @private +* @param {StringArray} signatures - list of (sorted) loop signatures +* @throws {Error} unexpected error +*/ +function updateREADME( signatures ) { + var parts; + var file; + var docs; + var out; + var err; + var i; + + file = readFile( README, FOPTS ); + if ( file instanceof Error ) { + throw file; + } + docs = []; + for ( i = 0; i < signatures.length; i++ ) { + docs.push( createDoc( signatures[ i ] ) ); + } + out = []; + parts = file.split( '\n' ); + out.push( parts[ 0 ] ); + out.push( '' ); + out.push( '' ); + out.push( charCodeList( DTYPES ).join( '\n' ) ); + out.push( '' ); + + parts = parts[ 1 ].split( '\n' ); + out.push( '' ); + + parts = parts[ 1 ].split( '\n' ); + out.push( parts[ 0 ] ); + out.push( '' ); + out.push( '' ); + out.push( docs.join( '\n' ) ); + + parts = parts[ 1 ].split( '\n' ); + out.push( '' ); + out.push( parts[ 1 ] ); + + err = writeFile( README, out.join( '\n' ), FOPTS ); + if ( err ) { + throw err; + } +} + +/** +* Updates the main header file. +* +* @private +* @param {StringArray} signatures - list of (sorted) loop signatures +* @throws {Error} unexpected error +*/ +function updateMainHeader( signatures ) { + var file; + var list; + var err; + var sig; + var ch; + var i; + + file = readFile( INCLUDE_MAIN, FOPTS ); + if ( file instanceof Error ) { + throw file; + } + list = []; + ch = signatures[ 0 ].charAt( 0 ); + for ( i = 0; i < signatures.length; i++ ) { + sig = signatures[ i ]; + if ( sig.charAt( 0 ) !== ch ) { + ch = sig.charAt( 0 ); + list.push( '' ); + } + list.push( '#include "mskfilter/'+sig+'.h"' ); + } + file = [ + substringBefore( file, '\n// BEGIN LOOPS' ), + '// BEGIN LOOPS', + list.join( '\n' ), + '// END LOOPS', + substringAfter( file, '// END LOOPS\n' ) + ].join( '\n' ); + + err = writeFile( INCLUDE_MAIN, file, FOPTS ); + if ( err ) { + throw err; + } +} + +/** +* Updates the package manifest. +* +* @private +* @param {StringArray} signatures - list of (sorted) loop signatures +* @throws {Error} unexpected error +*/ +function updateManifest( signatures ) { + var file; + var list; + var tmp; + var err; + var l; + var i; + var j; + + file = readJSON( MANIFEST, FOPTS ); + if ( file instanceof Error ) { + throw file; + } + list = []; + for ( i = 0; i < signatures.length; i++ ) { + list.push( './src/'+signatures[ i ]+'.c' ); + } + for ( j = 0; j < file.confs.length; j++ ) { + l = list.slice(); + + // Copy over non-signature source files... + tmp = file.confs[ j ].src; + for ( i = 0; i < tmp.length; i++ ) { + if ( RE_MANIFEST_LOOP_FILE.test( tmp[ i ] ) === false ) { + l.push( tmp[ i ] ); + } + } + // Replace the list of source files: + file.confs[ j ].src = l; + } + err = writeFile( MANIFEST, JSON.stringify( file, null, 2 )+'\n', FOPTS ); + if ( err ) { + throw err; + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var sigs; + + debug( 'Data types: %s', DTYPES.join( ', ' ) ); + + // Generate the list of loop signatures: + sigs = signatures( DTYPES ); + debug( 'Signatures: %s', '\n'+sigs.join( '\n' ) ); + + // Remove loop files from output directories: + debug( 'Clearing include directory: %s', INCLUDE_DIR ); + removeLoopFiles( INCLUDE_DIR ); + + debug( 'Clearing source directory: %s', SRC_DIR ); + removeLoopFiles( SRC_DIR ); + + // Create header files for the list of loop signatures: + debug( 'Creating header files...' ); + createHeaderFiles( sigs ); + + // Create source files for the list of loop signatures: + debug( 'Creating source files...' ); + createSourceFiles( sigs ); + + // Update the main header file to include the loop header files: + debug( 'Updating main header file: %s', INCLUDE_MAIN ); + updateMainHeader( sigs ); + + // Update the package manifest to include the loop source files: + debug( 'Updating manifest file: %s', MANIFEST ); + updateManifest( sigs ); + + // Update the package README to include the loop interfaces: + debug( 'Updating README file: %s', README ); + updateREADME( sigs ); + + debug( 'Finished.' ); +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/scripts/templates/docs.txt b/lib/node_modules/@stdlib/ndarray/base/mskfilter/scripts/templates/docs.txt index 912b72ad11c..062342107b4 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/scripts/templates/docs.txt +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/scripts/templates/docs.txt @@ -64,7 +64,7 @@ if ( mask == NULL ) { } // Create an output ndarray: -struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, ndims, shy, sy, oy, order, imode, nsubmodes, submodes ); +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); if ( y == NULL ) { fprintf( stderr, "Error allocating memory.\n" ); exit( EXIT_FAILURE ); diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/scripts/templates/source.txt b/lib/node_modules/@stdlib/ndarray/base/mskfilter/scripts/templates/source.txt index c6d1dbdeb5a..4c90ca04337 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/scripts/templates/source.txt +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/scripts/templates/source.txt @@ -62,9 +62,9 @@ * int64_t ndims = 0; * * // Define the array shapes: -* int64_t shx[] = { {{INPUT_NDARRAY_SHAPE_0D}} }; -* int64_t shm[] = { {{INPUT_NDARRAY_SHAPE_0D}} }; -* int64_t shy[] = { {{OUTPUT_NDARRAY_SHAPE_0D}} }; +* int64_t shx[] = {}; +* int64_t shm[] = {}; +* int64_t shy[] = {}; * * // Define the strides: * int64_t sx[] = { 0 }; From 4eeeb4622efcfe9e3e9c971f35b66f58e0b87e8d Mon Sep 17 00:00:00 2001 From: Jaysukh-409 Date: Tue, 24 Sep 2024 15:11:31 +0530 Subject: [PATCH 32/34] feat: update templates and run script --- .../@stdlib/ndarray/base/mskfilter/README.md | 5348 +++++++++++++++++ .../stdlib/ndarray/base/mskfilter/b_b.h | 150 + .../stdlib/ndarray/base/mskfilter/b_c.h | 150 + .../stdlib/ndarray/base/mskfilter/b_d.h | 150 + .../stdlib/ndarray/base/mskfilter/b_f.h | 150 + .../stdlib/ndarray/base/mskfilter/b_i.h | 150 + .../stdlib/ndarray/base/mskfilter/b_k.h | 150 + .../stdlib/ndarray/base/mskfilter/b_t.h | 150 + .../stdlib/ndarray/base/mskfilter/b_u.h | 150 + .../stdlib/ndarray/base/mskfilter/b_z.h | 150 + .../stdlib/ndarray/base/mskfilter/c_c.h | 150 + .../stdlib/ndarray/base/mskfilter/c_z.h | 150 + .../stdlib/ndarray/base/mskfilter/d_c.h | 150 + .../stdlib/ndarray/base/mskfilter/d_d.h | 150 + .../stdlib/ndarray/base/mskfilter/d_f.h | 150 + .../stdlib/ndarray/base/mskfilter/d_z.h | 150 + .../stdlib/ndarray/base/mskfilter/f_c.h | 150 + .../stdlib/ndarray/base/mskfilter/f_d.h | 150 + .../stdlib/ndarray/base/mskfilter/f_f.h | 150 + .../stdlib/ndarray/base/mskfilter/f_z.h | 150 + .../stdlib/ndarray/base/mskfilter/i_d.h | 150 + .../stdlib/ndarray/base/mskfilter/i_i.h | 150 + .../stdlib/ndarray/base/mskfilter/i_u.h | 150 + .../stdlib/ndarray/base/mskfilter/i_z.h | 150 + .../stdlib/ndarray/base/mskfilter/k_c.h | 150 + .../stdlib/ndarray/base/mskfilter/k_d.h | 150 + .../stdlib/ndarray/base/mskfilter/k_f.h | 150 + .../stdlib/ndarray/base/mskfilter/k_i.h | 150 + .../stdlib/ndarray/base/mskfilter/k_k.h | 150 + .../stdlib/ndarray/base/mskfilter/k_t.h | 150 + .../stdlib/ndarray/base/mskfilter/k_u.h | 150 + .../stdlib/ndarray/base/mskfilter/k_z.h | 150 + .../stdlib/ndarray/base/mskfilter/s_b.h | 150 + .../stdlib/ndarray/base/mskfilter/s_c.h | 150 + .../stdlib/ndarray/base/mskfilter/s_d.h | 150 + .../stdlib/ndarray/base/mskfilter/s_f.h | 150 + .../stdlib/ndarray/base/mskfilter/s_i.h | 150 + .../stdlib/ndarray/base/mskfilter/s_k.h | 150 + .../stdlib/ndarray/base/mskfilter/s_s.h | 150 + .../stdlib/ndarray/base/mskfilter/s_t.h | 150 + .../stdlib/ndarray/base/mskfilter/s_u.h | 150 + .../stdlib/ndarray/base/mskfilter/s_z.h | 150 + .../stdlib/ndarray/base/mskfilter/t_c.h | 150 + .../stdlib/ndarray/base/mskfilter/t_d.h | 150 + .../stdlib/ndarray/base/mskfilter/t_f.h | 150 + .../stdlib/ndarray/base/mskfilter/t_i.h | 150 + .../stdlib/ndarray/base/mskfilter/t_t.h | 150 + .../stdlib/ndarray/base/mskfilter/t_u.h | 150 + .../stdlib/ndarray/base/mskfilter/t_z.h | 150 + .../stdlib/ndarray/base/mskfilter/typedefs.h | 7 +- .../stdlib/ndarray/base/mskfilter/u_d.h | 150 + .../stdlib/ndarray/base/mskfilter/u_u.h | 150 + .../stdlib/ndarray/base/mskfilter/u_z.h | 150 + .../stdlib/ndarray/base/mskfilter/x_x.h | 150 + .../stdlib/ndarray/base/mskfilter/z_c.h | 150 + .../stdlib/ndarray/base/mskfilter/z_z.h | 150 + .../base/mskfilter/scripts/templates/docs.txt | 2 +- .../mskfilter/scripts/templates/source.txt | 84 +- .../@stdlib/ndarray/base/mskfilter/src/b_b.c | 2298 +++++++ .../@stdlib/ndarray/base/mskfilter/src/b_c.c | 2299 +++++++ .../@stdlib/ndarray/base/mskfilter/src/b_d.c | 2298 +++++++ .../@stdlib/ndarray/base/mskfilter/src/b_f.c | 2298 +++++++ .../@stdlib/ndarray/base/mskfilter/src/b_i.c | 2298 +++++++ .../@stdlib/ndarray/base/mskfilter/src/b_k.c | 2298 +++++++ .../@stdlib/ndarray/base/mskfilter/src/b_t.c | 2298 +++++++ .../@stdlib/ndarray/base/mskfilter/src/b_u.c | 2298 +++++++ .../@stdlib/ndarray/base/mskfilter/src/b_z.c | 2299 +++++++ .../@stdlib/ndarray/base/mskfilter/src/c_c.c | 2299 +++++++ .../@stdlib/ndarray/base/mskfilter/src/c_z.c | 2300 +++++++ .../@stdlib/ndarray/base/mskfilter/src/d_c.c | 2299 +++++++ .../@stdlib/ndarray/base/mskfilter/src/d_d.c | 2298 +++++++ .../@stdlib/ndarray/base/mskfilter/src/d_f.c | 2298 +++++++ .../@stdlib/ndarray/base/mskfilter/src/d_z.c | 2299 +++++++ .../@stdlib/ndarray/base/mskfilter/src/f_c.c | 2299 +++++++ .../@stdlib/ndarray/base/mskfilter/src/f_d.c | 2298 +++++++ .../@stdlib/ndarray/base/mskfilter/src/f_f.c | 2298 +++++++ .../@stdlib/ndarray/base/mskfilter/src/f_z.c | 2299 +++++++ .../@stdlib/ndarray/base/mskfilter/src/i_d.c | 2298 +++++++ .../@stdlib/ndarray/base/mskfilter/src/i_i.c | 2298 +++++++ .../@stdlib/ndarray/base/mskfilter/src/i_u.c | 2298 +++++++ .../@stdlib/ndarray/base/mskfilter/src/i_z.c | 2299 +++++++ .../@stdlib/ndarray/base/mskfilter/src/k_c.c | 2299 +++++++ .../@stdlib/ndarray/base/mskfilter/src/k_d.c | 2298 +++++++ .../@stdlib/ndarray/base/mskfilter/src/k_f.c | 2298 +++++++ .../@stdlib/ndarray/base/mskfilter/src/k_i.c | 2298 +++++++ .../@stdlib/ndarray/base/mskfilter/src/k_k.c | 2298 +++++++ .../@stdlib/ndarray/base/mskfilter/src/k_t.c | 2298 +++++++ .../@stdlib/ndarray/base/mskfilter/src/k_u.c | 2298 +++++++ .../@stdlib/ndarray/base/mskfilter/src/k_z.c | 2299 +++++++ .../@stdlib/ndarray/base/mskfilter/src/s_b.c | 2298 +++++++ .../@stdlib/ndarray/base/mskfilter/src/s_c.c | 2299 +++++++ .../@stdlib/ndarray/base/mskfilter/src/s_d.c | 2298 +++++++ .../@stdlib/ndarray/base/mskfilter/src/s_f.c | 2298 +++++++ .../@stdlib/ndarray/base/mskfilter/src/s_i.c | 2298 +++++++ .../@stdlib/ndarray/base/mskfilter/src/s_k.c | 2298 +++++++ .../@stdlib/ndarray/base/mskfilter/src/s_s.c | 2298 +++++++ .../@stdlib/ndarray/base/mskfilter/src/s_t.c | 2298 +++++++ .../@stdlib/ndarray/base/mskfilter/src/s_u.c | 2298 +++++++ .../@stdlib/ndarray/base/mskfilter/src/s_z.c | 2299 +++++++ .../@stdlib/ndarray/base/mskfilter/src/t_c.c | 2299 +++++++ .../@stdlib/ndarray/base/mskfilter/src/t_d.c | 2298 +++++++ .../@stdlib/ndarray/base/mskfilter/src/t_f.c | 2298 +++++++ .../@stdlib/ndarray/base/mskfilter/src/t_i.c | 2298 +++++++ .../@stdlib/ndarray/base/mskfilter/src/t_t.c | 2298 +++++++ .../@stdlib/ndarray/base/mskfilter/src/t_u.c | 2298 +++++++ .../@stdlib/ndarray/base/mskfilter/src/t_z.c | 2299 +++++++ .../@stdlib/ndarray/base/mskfilter/src/u_d.c | 2298 +++++++ .../@stdlib/ndarray/base/mskfilter/src/u_u.c | 2298 +++++++ .../@stdlib/ndarray/base/mskfilter/src/u_z.c | 2299 +++++++ .../@stdlib/ndarray/base/mskfilter/src/x_x.c | 2299 +++++++ .../@stdlib/ndarray/base/mskfilter/src/z_c.c | 2300 +++++++ .../@stdlib/ndarray/base/mskfilter/src/z_z.c | 2299 +++++++ 112 files changed, 137605 insertions(+), 49 deletions(-) create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/b_b.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/b_c.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/b_d.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/b_f.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/b_i.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/b_k.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/b_t.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/b_u.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/b_z.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/c_c.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/c_z.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/d_c.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/d_d.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/d_f.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/d_z.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/f_c.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/f_d.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/f_f.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/f_z.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/i_d.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/i_i.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/i_u.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/i_z.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/k_c.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/k_d.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/k_f.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/k_i.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/k_k.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/k_t.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/k_u.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/k_z.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/s_b.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/s_c.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/s_d.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/s_f.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/s_i.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/s_k.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/s_s.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/s_t.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/s_u.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/s_z.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/t_c.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/t_d.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/t_f.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/t_i.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/t_t.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/t_u.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/t_z.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/u_d.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/u_u.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/u_z.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/x_x.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/z_c.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/include/stdlib/ndarray/base/mskfilter/z_z.h create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/b_b.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/b_c.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/b_d.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/b_f.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/b_i.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/b_k.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/b_t.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/b_u.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/b_z.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/c_c.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/c_z.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/d_c.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/d_d.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/d_f.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/d_z.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/f_c.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/f_d.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/f_f.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/f_z.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/i_d.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/i_i.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/i_u.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/i_z.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/k_c.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/k_d.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/k_f.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/k_i.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/k_k.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/k_t.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/k_u.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/k_z.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/s_b.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/s_c.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/s_d.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/s_f.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/s_i.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/s_k.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/s_s.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/s_t.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/s_u.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/s_z.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/t_c.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/t_d.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/t_f.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/t_i.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/t_t.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/t_u.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/t_z.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/u_d.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/u_u.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/u_z.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/x_x.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/z_c.c create mode 100644 lib/node_modules/@stdlib/ndarray/base/mskfilter/src/z_z.c diff --git a/lib/node_modules/@stdlib/ndarray/base/mskfilter/README.md b/lib/node_modules/@stdlib/ndarray/base/mskfilter/README.md index 1a65817a6d8..f7ccba96b4d 100644 --- a/lib/node_modules/@stdlib/ndarray/base/mskfilter/README.md +++ b/lib/node_modules/@stdlib/ndarray/base/mskfilter/README.md @@ -161,6 +161,5354 @@ console.log( ndarray2array( y.data, y.shape, y.strides, y.offset, y.order ) ); + + +* * * + +
+ +## C APIs + + + +
+ +Character codes for data types: + + + + + +- **x**: `bool` (boolean). +- **c**: `complex64` (single-precision floating-point complex number). +- **z**: `complex128` (double-precision floating-point complex number). +- **f**: `float32` (single-precision floating-point number). +- **d**: `float64` (double-precision floating-point number). +- **k**: `int16` (signed 16-bit integer). +- **i**: `int32` (signed 32-bit integer). +- **s**: `int8` (signed 8-bit integer). +- **t**: `uint16` (unsigned 16-bit integer). +- **u**: `uint32` (unsigned 32-bit integer). +- **b**: `uint8` (unsigned 8-bit integer). + + + +Function name suffix naming convention: + +```text +stdlib_ndarray_mskfilter__ +``` + +For example, + + + +```c +void stdlib_ndarray_mskfilter_d_d(...) {...} +``` + +is a function which accepts one double-precision floating-point input ndarray, one mask ndarray and one double-precision floating-point output ndarray. In other words, the suffix encodes the function type signature. + + + + + +
+ +### Usage + +```c +#include "stdlib/ndarray/base/mskfilter.h" +``` + + + + + +#### stdlib_ndarray_mskfilter_b_b( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_UINT8; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 2, 1 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 1 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_b_b( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_b_b( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_b_c( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_COMPLEX64; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 2, 1 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 8 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_b_c( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_b_c( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_b_d( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_FLOAT64; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 2, 1 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 8 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_b_d( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_b_d( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_b_f( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_FLOAT32; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 2, 1 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 4 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_b_f( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_b_f( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_b_i( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_INT32; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 2, 1 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 4 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_b_i( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_b_i( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_b_k( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_INT16; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 2, 1 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 2 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_b_k( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_b_k( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_b_t( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_UINT16; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 2, 1 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 2 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_b_t( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_b_t( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_b_u( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_UINT32; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 2, 1 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 4 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_b_u( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_b_u( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_b_z( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_COMPLEX128; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 2, 1 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 16 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_b_z( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_b_z( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_c_c( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_COMPLEX64; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_COMPLEX64; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 16, 8 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 8 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_c_c( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_c_c( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_c_z( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_COMPLEX64; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_COMPLEX128; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 16, 8 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 16 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_c_z( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_c_z( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_d_c( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_FLOAT64; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_COMPLEX64; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 16, 8 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 8 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_d_c( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_d_c( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_d_d( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_FLOAT64; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_FLOAT64; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 16, 8 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 8 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_d_d( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_d_d( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_d_f( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_FLOAT64; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_FLOAT32; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 16, 8 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 4 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_d_f( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_d_f( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_d_z( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_FLOAT64; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_COMPLEX128; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 16, 8 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 16 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_d_z( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_d_z( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_f_c( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_FLOAT32; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_COMPLEX64; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 8, 4 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 8 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_f_c( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_f_c( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_f_d( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_FLOAT32; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_FLOAT64; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 8, 4 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 8 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_f_d( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_f_d( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_f_f( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_FLOAT32; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_FLOAT32; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 8, 4 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 4 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_f_f( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_f_f( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_f_z( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_FLOAT32; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_COMPLEX128; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 8, 4 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 16 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_f_z( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_f_z( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_i_d( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_INT32; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_FLOAT64; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 8, 4 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 8 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_i_d( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_i_d( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_i_i( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_INT32; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_INT32; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 8, 4 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 4 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_i_i( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_i_i( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_i_u( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_INT32; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_UINT32; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 8, 4 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 4 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_i_u( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_i_u( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_i_z( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_INT32; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_COMPLEX128; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 8, 4 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 16 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_i_z( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_i_z( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_k_c( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_INT16; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_COMPLEX64; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 4, 2 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 8 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_k_c( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_k_c( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_k_d( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_INT16; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_FLOAT64; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 4, 2 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 8 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_k_d( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_k_d( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_k_f( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_INT16; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_FLOAT32; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 4, 2 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 4 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_k_f( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_k_f( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_k_i( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_INT16; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_INT32; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 4, 2 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 4 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_k_i( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_k_i( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_k_k( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_INT16; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_INT16; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 4, 2 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 2 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_k_k( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_k_k( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_k_t( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_INT16; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_UINT16; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 4, 2 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 2 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_k_t( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_k_t( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_k_u( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_INT16; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_UINT32; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 4, 2 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 4 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_k_u( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_k_u( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_k_z( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_INT16; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_COMPLEX128; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 4, 2 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 16 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_k_z( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_k_z( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_s_b( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_INT8; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_UINT8; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 2, 1 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 1 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_s_b( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_s_b( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_s_c( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_INT8; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_COMPLEX64; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 2, 1 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 8 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_s_c( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_s_c( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_s_d( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_INT8; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_FLOAT64; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 2, 1 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 8 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_s_d( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_s_d( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_s_f( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_INT8; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_FLOAT32; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 2, 1 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 4 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_s_f( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_s_f( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_s_i( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_INT8; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_INT32; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 2, 1 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 4 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_s_i( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_s_i( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_s_k( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_INT8; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_INT16; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 2, 1 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 2 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_s_k( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_s_k( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_s_s( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_INT8; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_INT8; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 2, 1 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 1 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_s_s( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_s_s( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_s_t( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_INT8; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_UINT16; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 2, 1 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 2 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_s_t( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_s_t( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_s_u( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_INT8; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_UINT32; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 2, 1 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 4 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_s_u( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_s_u( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_s_z( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_INT8; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_COMPLEX128; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 2, 1 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 16 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_s_z( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_s_z( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_t_c( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_UINT16; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_COMPLEX64; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 4, 2 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 8 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_t_c( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_t_c( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_t_d( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_UINT16; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_FLOAT64; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 4, 2 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 8 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_t_d( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_t_d( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_t_f( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_UINT16; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_FLOAT32; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 4, 2 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 4 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_t_f( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_t_f( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_t_i( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_UINT16; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_INT32; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 4, 2 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 4 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_t_i( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_t_i( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_t_t( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_UINT16; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_UINT16; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 4, 2 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 2 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_t_t( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_t_t( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_t_u( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_UINT16; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_UINT32; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 4, 2 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 4 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_t_u( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_t_u( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_t_z( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_UINT16; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_COMPLEX128; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 4, 2 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 16 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_t_z( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_t_z( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_u_d( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_UINT32; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_FLOAT64; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 8, 4 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 8 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_u_d( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_u_d( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_u_u( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_UINT32; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_UINT32; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 8, 4 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 4 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_u_u( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_u_u( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_u_z( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_UINT32; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_COMPLEX128; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 8, 4 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 16 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_u_z( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_u_z( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_x_x( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_BOOL; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_BOOL; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 2, 1 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 1 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_x_x( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_x_x( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_z_c( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_COMPLEX128; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_COMPLEX64; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 32, 16 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 8 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_z_c( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_z_c( struct ndarray *arrays[] ); +``` + +#### stdlib_ndarray_mskfilter_z_z( \*arrays\[] ) + +Applies a mask to a provided input ndarray and assigns unmasked values to elements in a provided one-dimensional output ndarray. + +```c +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/ctor.h" +#include +#include +#include + +// Define the ndarray data types: +enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_COMPLEX128; +enum STDLIB_NDARRAY_DTYPE mdtype = STDLIB_NDARRAY_UINT8; +enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_COMPLEX128; + +// Create underlying byte arrays: +uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +uint8_t mbuf[] = { 0, 0, 0, 0 }; +uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +// Define the number of dimensions: +int64_t ndims = 2; + +// Define the array shapes: +int64_t shx[] = { 2, 2 }; +int64_t shy[] = { 2, 2 }; +int64_t shm[] = { 4 }; + +// Define the strides: +int64_t sx[] = { 32, 16 }; +int64_t sm[] = { 2, 1 }; +int64_t sy[] = { 16 }; + +// Define the offsets: +int64_t ox = 0; +int64_t om = 0; +int64_t oy = 0; + +// Define the array order: +enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + +// Specify the index mode: +enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + +// Specify the subscript index modes: +int8_t submodes[] = { imode }; +int64_t nsubmodes = 1; + +// Create an input ndarray: +struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes ); +if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create a mask ndarray: +struct ndarray *mask = stdlib_ndarray_allocate( mdtype, mbuf, ndims, shm, sm, om, order, imode, nsubmodes, submodes ); +if ( mask == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an output ndarray: +struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, 1, shy, sy, oy, order, imode, nsubmodes, submodes ); +if ( y == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( EXIT_FAILURE ); +} + +// Create an array containing the ndarrays: +struct ndarray *arrays[] = { x, mask, y }; + +int8_t status = stdlib_ndarray_mskfilter_z_z( arrays ); +if ( status != 0 ) { + fprintf( stderr, "Error during computation.\n" ); + exit( EXIT_FAILURE ); +} + +// ... + +// Free allocated memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +stdlib_ndarray_free( y ); +``` + +The function accepts the following arguments: + +- **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray, whose second element is a pointer to a mask ndarray, and whose third element is a pointer to an output ndarray. + +```c +int8_t stdlib_ndarray_mskfilter_z_z( struct ndarray *arrays[] ); +``` + + + + + + + + + +
+ + + + + +
+ +
+ + + + + +* * * + +
+ +### Examples + +
+ + + +
+ + + +
+ + + + + + +