Skip to content

Commit c120bb0

Browse files
committed
Auto-generated commit
1 parent d4fb495 commit c120bb0

File tree

12 files changed

+1063
-6
lines changed

12 files changed

+1063
-6
lines changed

CHANGELOG.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<section class="release" id="unreleased">
66

7-
## Unreleased (2024-11-22)
7+
## Unreleased (2024-11-25)
88

99
<section class="packages">
1010

@@ -264,6 +264,7 @@
264264

265265
##### Features
266266

267+
- [`cb27ec4`](https://github.com/stdlib-js/stdlib/commit/cb27ec42bd7e65c46877e57064d36ff9b38b502b) - add `array/base/mskbinary4d` [(#3196)](https://github.com/stdlib-js/stdlib/pull/3196)
267268
- [`c328fc5`](https://github.com/stdlib-js/stdlib/commit/c328fc515fc925ee717ed9cd844cca83a61da806) - add `array/base/mskbinary3d` [(#3193)](https://github.com/stdlib-js/stdlib/pull/3193)
268269

269270
</section>
@@ -274,9 +275,9 @@
274275

275276
##### Closed Issues
276277

277-
This release closes the following issue:
278+
A total of 2 issues were closed in this release:
278279

279-
[#3178](https://github.com/stdlib-js/stdlib/issues/3178)
280+
[#3178](https://github.com/stdlib-js/stdlib/issues/3178), [#3179](https://github.com/stdlib-js/stdlib/issues/3179)
280281

281282
</section>
282283

@@ -410,9 +411,9 @@ A total of 2 issues were closed in this release:
410411

411412
### Closed Issues
412413

413-
A total of 3 issues were closed in this release:
414+
A total of 4 issues were closed in this release:
414415

415-
[#3135](https://github.com/stdlib-js/stdlib/issues/3135), [#3138](https://github.com/stdlib-js/stdlib/issues/3138), [#3178](https://github.com/stdlib-js/stdlib/issues/3178)
416+
[#3135](https://github.com/stdlib-js/stdlib/issues/3135), [#3138](https://github.com/stdlib-js/stdlib/issues/3138), [#3178](https://github.com/stdlib-js/stdlib/issues/3178), [#3179](https://github.com/stdlib-js/stdlib/issues/3179)
416417

417418
</section>
418419

@@ -422,9 +423,10 @@ A total of 3 issues were closed in this release:
422423

423424
### Contributors
424425

425-
A total of 4 people contributed to this release. Thank you to the following contributors:
426+
A total of 5 people contributed to this release. Thank you to the following contributors:
426427

427428
- Aayush Khanna
429+
- Abhijit
428430
- Athan Reines
429431
- Philipp Burckhardt
430432
- Rylan Yang
@@ -439,6 +441,7 @@ A total of 4 people contributed to this release. Thank you to the following cont
439441

440442
<details>
441443

444+
- [`cb27ec4`](https://github.com/stdlib-js/stdlib/commit/cb27ec42bd7e65c46877e57064d36ff9b38b502b) - **feat:** add `array/base/mskbinary4d` [(#3196)](https://github.com/stdlib-js/stdlib/pull/3196) _(by Abhijit, Athan Reines)_
442445
- [`e3a2173`](https://github.com/stdlib-js/stdlib/commit/e3a2173a24bd8634f333cace626fc2d71740ebd3) - **feat:** add `every` method to `array/fixed-endian-factory` [(#3200)](https://github.com/stdlib-js/stdlib/pull/3200) _(by Aayush Khanna, Athan Reines)_
443446
- [`c328fc5`](https://github.com/stdlib-js/stdlib/commit/c328fc515fc925ee717ed9cd844cca83a61da806) - **feat:** add `array/base/mskbinary3d` [(#3193)](https://github.com/stdlib-js/stdlib/pull/3193) _(by Rylan Yang, Athan Reines, stdlib-bot)_
444447
- [`9ba0dbd`](https://github.com/stdlib-js/stdlib/commit/9ba0dbd839707695a05fda5d4f50d67c5aba52f7) - **chore:** use relative paths to load main package export _(by Philipp Burckhardt)_

CONTRIBUTORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ Roman Stetsyk <[email protected]>
8383
8484
Ruthwik Chikoti <[email protected]>
8585
Ryan Seal <[email protected]>
86+
Rylan Yang <[email protected]>
8687
Sai Srikar Dumpeti <[email protected]>
8788
SarthakPaandey <[email protected]>
8889
Saurabh Singh <[email protected]>

base/mskbinary4d/README.md

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2024 The Stdlib Authors.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
21+
# mskbinary4d
22+
23+
> Apply a binary callback to elements in two four-dimensional nested input arrays according to elements in a four-dimensional nested mask array and assign results to elements in a four-dimensional nested output array.
24+
25+
<section class="intro">
26+
27+
</section>
28+
29+
<!-- /.intro -->
30+
31+
<section class="usage">
32+
33+
## Usage
34+
35+
```javascript
36+
var mskbinary4d = require( '@stdlib/array/base/mskbinary4d' );
37+
```
38+
39+
#### mskbinary4d( arrays, shape, fcn )
40+
41+
Applies a binary callback to elements in two four-dimensional nested input arrays according to elements in a four-dimensional nested mask array and assigns results to elements in a four-dimensional nested output array.
42+
43+
```javascript
44+
var add = require( '@stdlib/math/base/ops/add' );
45+
var zeros4d = require( '@stdlib/array/base/zeros4d' );
46+
47+
var x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ];
48+
var z = zeros4d( [ 1, 1, 2, 2 ] );
49+
50+
var mask = [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ];
51+
52+
var shape = [ 1, 1, 2, 2 ];
53+
54+
mskbinary4d( [ x, x, mask, z ], shape, add );
55+
// z => [ [ [ [ 2.0, 0.0 ], [ 6.0, 8.0 ] ] ] ]
56+
```
57+
58+
The function accepts the following arguments:
59+
60+
- **arrays**: array-like object containing two input nested arrays, an input nested mask array, and one output nested array.
61+
- **shape**: array shape.
62+
- **fcn**: binary function to apply.
63+
64+
</section>
65+
66+
<!-- /.usage -->
67+
68+
<section class="notes">
69+
70+
## Notes
71+
72+
- The function assumes that the input and output arrays have the same shape.
73+
74+
</section>
75+
76+
<!-- /.notes -->
77+
78+
<section class="examples">
79+
80+
## Examples
81+
82+
<!-- eslint no-undef: "error" -->
83+
84+
```javascript
85+
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory;
86+
var bernoulli = require( '@stdlib/random/base/bernoulli' ).factory;
87+
var filled4dBy = require( '@stdlib/array/base/filled4d-by' );
88+
var zeros4d = require( '@stdlib/array/base/zeros4d' );
89+
var add = require( '@stdlib/math/base/ops/add' );
90+
var mskbinary4d = require( '@stdlib/array/base/mskbinary4d' );
91+
92+
var shape = [ 2, 1, 3, 3 ];
93+
94+
var x = filled4dBy( shape, discreteUniform( -100, 100 ) );
95+
console.log( x );
96+
97+
var y = filled4dBy( shape, discreteUniform( -100, 100 ) );
98+
console.log( y );
99+
100+
var mask = filled4dBy( shape, bernoulli( 0.5 ) );
101+
console.log( mask );
102+
103+
var z = zeros4d( shape );
104+
console.log( z );
105+
106+
mskbinary4d( [ x, y, mask, z ], shape, add );
107+
console.log( z );
108+
```
109+
110+
</section>
111+
112+
<!-- /.examples -->
113+
114+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
115+
116+
<section class="related">
117+
118+
</section>
119+
120+
<!-- /.related -->
121+
122+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
123+
124+
<section class="links">
125+
126+
</section>
127+
128+
<!-- /.links -->
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2024 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var uniform = require( '@stdlib/random/base/uniform' ).factory;
25+
var bernoulli = require( '@stdlib/random/base/bernoulli' ).factory;
26+
var isnan = require( '@stdlib/math/base/assert/is-nan' );
27+
var pow = require( '@stdlib/math/base/special/pow' );
28+
var floor = require( '@stdlib/math/base/special/floor' );
29+
var add = require( '@stdlib/math/base/ops/add' );
30+
var filled4dBy = require( './../../../base/filled4d-by' );
31+
var zeros4d = require( './../../../base/zeros4d' );
32+
var numel = require( '@stdlib/ndarray/base/numel' );
33+
var pkg = require( './../package.json' ).name;
34+
var mskbinary4d = require( './../lib' );
35+
36+
37+
// FUNCTIONS //
38+
39+
/**
40+
* Creates a benchmark function.
41+
*
42+
* @private
43+
* @param {PositiveIntegerArray} shape - array shape
44+
* @returns {Function} benchmark function
45+
*/
46+
function createBenchmark( shape ) {
47+
var arrays;
48+
var x;
49+
var y;
50+
var z;
51+
var m;
52+
53+
x = filled4dBy( shape, uniform( -100.0, 100.0 ) );
54+
y = filled4dBy( shape, uniform( -100.0, 100.0 ) );
55+
m = filled4dBy( shape, bernoulli( 0.5 ) );
56+
z = zeros4d( shape );
57+
58+
arrays = [ x, y, m, z ];
59+
60+
return benchmark;
61+
62+
/**
63+
* Benchmark function.
64+
*
65+
* @private
66+
* @param {Benchmark} b - benchmark instance
67+
*/
68+
function benchmark( b ) {
69+
var i0;
70+
var i1;
71+
var i2;
72+
var i3;
73+
var i;
74+
75+
b.tic();
76+
for ( i = 0; i < b.iterations; i++ ) {
77+
mskbinary4d( arrays, shape, add );
78+
i3 = i % shape[ 0 ];
79+
i2 = i % shape[ 1 ];
80+
i1 = i % shape[ 2 ];
81+
i0 = i % shape[ 3 ];
82+
if ( isnan( arrays[ 3 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) {
83+
b.fail( 'should not return NaN' );
84+
}
85+
}
86+
b.toc();
87+
88+
i3 = i % shape[ 0 ];
89+
i2 = i % shape[ 1 ];
90+
i1 = i % shape[ 2 ];
91+
i0 = i % shape[ 3 ];
92+
if ( isnan( arrays[ 3 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) {
93+
b.fail( 'should not return NaN' );
94+
}
95+
b.pass( 'benchmark finished' );
96+
b.end();
97+
}
98+
}
99+
100+
101+
// MAIN //
102+
103+
/**
104+
* Main execution sequence.
105+
*
106+
* @private
107+
*/
108+
function main() {
109+
var min;
110+
var max;
111+
var sh;
112+
var N;
113+
var f;
114+
var i;
115+
116+
min = 1; // 10^min
117+
max = 6; // 10^max
118+
119+
for ( i = min; i <= max; i++ ) {
120+
N = floor( pow( pow( 10, i ), 1.0/4.0 ) );
121+
sh = [ N, N, N, N ];
122+
f = createBenchmark( sh );
123+
bench( pkg+'::equidimensional:size='+numel( sh ), f );
124+
}
125+
}
126+
127+
main();

base/mskbinary4d/docs/repl.txt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
{{alias}}( arrays, shape, fcn )
3+
Applies a binary callback to elements in two four-dimensional nested input
4+
arrays according to elements in a four-dimensional nested mask array and
5+
assigns results to elements in a four-dimensional nested output array.
6+
7+
An element in an input array is "masked" if the corresponding element in the
8+
mask array is non-zero.
9+
10+
Parameters
11+
----------
12+
arrays: ArrayLikeObject
13+
Array-like object containing two input nested arrays, an input nested
14+
mask array, and one output nested array.
15+
16+
shape: Array<integer>
17+
Array shape.
18+
19+
fcn: Function
20+
Binary callback.
21+
22+
Examples
23+
--------
24+
> var x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ];
25+
> var y = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ];
26+
> var m = [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ];
27+
> var z = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ];
28+
> var shape = [ 1, 1, 2, 2 ];
29+
> {{alias}}( [ x, y, m, z ], shape, {{alias:@stdlib/math/base/ops/add}} );
30+
> z
31+
[ [ [ [ 2.0, 0.0 ], [ 6.0, 8.0 ] ] ] ]
32+
33+
See Also
34+
--------
35+

0 commit comments

Comments
 (0)