Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add ndarray/base/mskfilter #2604

Draft
wants to merge 37 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
2836e0d
chore: create folder structure and add example
Jaysukh-409 Jul 15, 2024
67dfb52
feat: add kernels for 0d ndarray
Jaysukh-409 Jul 29, 2024
2f0ba4c
feat: add kernels for 1d ndarray
Jaysukh-409 Jul 30, 2024
d5bcb07
refactor: update the implementation for 1d kernels
Jaysukh-409 Aug 1, 2024
5010468
feat: add kernels for 2d ndarray
Jaysukh-409 Aug 1, 2024
6f3992f
docs: update description of loop kernel
Jaysukh-409 Aug 2, 2024
ecffc55
docs: refactor JSDoc example for loop kernels
Jaysukh-409 Aug 2, 2024
f531567
refactor: update variable name for consistent naming convention
Jaysukh-409 Aug 2, 2024
8ff83b4
feat: add kernels for 3d ndarray
Jaysukh-409 Aug 3, 2024
4039020
feat: add kernels for nd ndarray
Jaysukh-409 Aug 3, 2024
9422eb5
feat: add kernels for 4d ndarray
Jaysukh-409 Aug 5, 2024
f318edb
feat: add kernels for 5d ndarray
Jaysukh-409 Aug 5, 2024
7235a97
feat: add kernels for 6d ndarray
Jaysukh-409 Aug 5, 2024
d7683e0
feat: add kernels for 7d ndarray
Jaysukh-409 Aug 5, 2024
ad939d1
feat: add kernels for 8d ndarray
Jaysukh-409 Aug 5, 2024
f149847
feat: add kernels for 9d ndarray
Jaysukh-409 Aug 5, 2024
121db5a
feat: add kernels for 10d ndarray
Jaysukh-409 Aug 5, 2024
f1e0a81
docs: fix copy-paste error
Jaysukh-409 Aug 5, 2024
611cbcc
Merge branch 'develop' into ndarray/base/mskfilter
Jaysukh-409 Aug 8, 2024
467a34f
refactor: apply suggestions
Jaysukh-409 Aug 8, 2024
db07de8
test: add tests for 0d ndarray
Jaysukh-409 Aug 10, 2024
da81461
test: add tests for 1d ndarray
Jaysukh-409 Aug 10, 2024
7515b00
bench: add benchmark files
Jaysukh-409 Aug 13, 2024
e2ac30c
docs: added examples in readme
Jaysukh-409 Aug 14, 2024
f8926fb
Apply suggestions from code review
kgryte Aug 14, 2024
c193d8b
test: add tests for 2d ndaray
Jaysukh-409 Aug 16, 2024
11cb348
Merge branch 'ndarray/base/mskfilter' of https://github.com/Jaysukh-4…
Jaysukh-409 Aug 16, 2024
3ed9b3d
docs: add repl and typescript declaration
Jaysukh-409 Aug 16, 2024
59c2e81
test: add test for 3d to nd ndarray
Jaysukh-409 Aug 19, 2024
099e730
refactor: updated the implementation of mskfilter
Jaysukh-409 Aug 20, 2024
eaec078
refactor: apply suggestions
Jaysukh-409 Aug 21, 2024
1e848e9
Merge branch 'ndarray/base/mskfilter' of https://github.com/Jaysukh-4…
Jaysukh-409 Aug 21, 2024
1d1acea
feat: update scripts
Jaysukh-409 Sep 16, 2024
9c1003c
feat: update scripts and templates
Jaysukh-409 Sep 16, 2024
4eeeb46
feat: update templates and run script
Jaysukh-409 Sep 24, 2024
4e40c79
feat: add macros for 1d and 2d ndarray
Jaysukh-409 Sep 30, 2024
4d0ae78
fix: remove the unused variables
Jaysukh-409 Oct 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions lib/node_modules/@stdlib/ndarray/base/mskfilter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<!--

@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.

-->

# mskfilter

> Apply a mask to a provided input ndarray and assign unmasked values to elements in a provided one-dimensional output ndarray.

<section class="intro">

</section>

<!-- /.intro -->

<section class="usage">

## Usage

```javascript
var mskfilter = require( '@stdlib/ndarray/base/mskfilter' );
```

#### mskfilter ( arrays )
kgryte marked this conversation as resolved.
Show resolved Hide resolved

Apply a mask to a provided input ndarray and assign unmasked values to elements in a provided one-dimensional output ndarray.
Jaysukh-409 marked this conversation as resolved.
Show resolved Hide resolved

```javascript
```

The function accepts the following arguments:

- **arrays**: array-like object containing input ndarray, mask ndarray and one dimensional output ndarray.
Jaysukh-409 marked this conversation as resolved.
Show resolved Hide resolved

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).

</section>

<!-- /.usage -->

<section class="notes">

</section>

<!-- /.notes -->

<section class="examples">

## Examples

```javascript
```

</section>

<!-- /.examples -->
Jaysukh-409 marked this conversation as resolved.
Show resolved Hide resolved
89 changes: 89 additions & 0 deletions lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/0d.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/**
* @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 = [];
*
* // 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 ] ),
Jaysukh-409 marked this conversation as resolved.
Show resolved Hide resolved
* 'shape': shape,
* 'strides': sx,
* 'offset': ox,
* 'order': 'row-major'
* };
*
* var mask = {
* 'dtype': 'uint8',
* 'data': new Uint8Array( [ 1, 0, 1, 0, 1 ] ),
* 'shape': shape,
* 'strides': sm,
* 'offset': om,
* 'order': 'row-major'
* };
*
* var y = {
* 'dtype': 'float64',
* 'data': new Float64Array( 3 ),
* 'shape': [ 3 ],
Jaysukh-409 marked this conversation as resolved.
Show resolved Hide resolved
* 'strides': sy,
* 'offset': 0,
* 'order': 'row-major'
* };
*
* mskfilter0d( x, mask, y );
*
* console.log( y.data );
* // => <Float64Array>[ 1.0, 0.0, 0.0 ]
*/
function mskfilter0d( x, mask, y ) {
if ( mask.data[ mask.offset ] ) {
y.data[ y.offset ] = x.data[ x.offset ];
}
}


// EXPORTS //

module.exports = mskfilter0d;
110 changes: 110 additions & 0 deletions lib/node_modules/@stdlib/ndarray/base/mskfilter/lib/0d_accessors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/**
* @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' );
Jaysukh-409 marked this conversation as resolved.
Show resolved Hide resolved
*
* // 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 ] ),
Jaysukh-409 marked this conversation as resolved.
Show resolved Hide resolved
* '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 ]
* };
*
* mskfilter0d( x, mask, y );
*
* var v = y.data.get( 0 );
* // returns <Complex64>
*
* 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 = mskfilter0d;
Loading
Loading