Skip to content

Commit ea263f9

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

File tree

11 files changed

+1168
-4
lines changed

11 files changed

+1168
-4
lines changed

CHANGELOG.md

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

265265
##### Features
266266

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

@@ -275,9 +276,9 @@
275276

276277
##### Closed Issues
277278

278-
A total of 2 issues were closed in this release:
279+
A total of 3 issues were closed in this release:
279280

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

282283
</section>
283284

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

412413
### Closed Issues
413414

414-
A total of 4 issues were closed in this release:
415+
A total of 5 issues were closed in this release:
415416

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)
417+
[#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), [#3180](https://github.com/stdlib-js/stdlib/issues/3180)
417418

418419
</section>
419420

@@ -441,6 +442,7 @@ A total of 5 people contributed to this release. Thank you to the following cont
441442

442443
<details>
443444

445+
- [`34ae5c9`](https://github.com/stdlib-js/stdlib/commit/34ae5c9570bf6428dc5bede92557ae56981554c2) - **feat:** add `array/base/mskbinary5d` [(#3198)](https://github.com/stdlib-js/stdlib/pull/3198) _(by Abhijit)_
444446
- [`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)_
445447
- [`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)_
446448
- [`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)_

base/mskbinary5d/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+
# mskbinary5d
22+
23+
> Apply a binary callback to elements in two five-dimensional nested input arrays according to elements in a five-dimensional nested mask array and assign results to elements in a five-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 mskbinary5d = require( '@stdlib/array/base/mskbinary5d' );
37+
```
38+
39+
#### mskbinary5d( arrays, shape, fcn )
40+
41+
Applies a binary callback to elements in two five-dimensional nested input arrays according to elements in a five-dimensional nested mask array and assigns results to elements in a five-dimensional nested output array.
42+
43+
```javascript
44+
var add = require( '@stdlib/math/base/ops/add' );
45+
var zeros5d = require( '@stdlib/array/base/zeros5d' );
46+
47+
var x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ];
48+
var z = zeros5d( [ 1, 1, 1, 2, 2 ] );
49+
50+
var mask = [ [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ] ];
51+
52+
var shape = [ 1, 1, 1, 2, 2 ];
53+
54+
mskbinary5d( [ 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 filled5dBy = require( '@stdlib/array/base/filled5d-by' );
88+
var zeros5d = require( '@stdlib/array/base/zeros5d' );
89+
var add = require( '@stdlib/math/base/ops/add' );
90+
var mskbinary5d = require( '@stdlib/array/base/mskbinary5d' );
91+
92+
var shape = [ 1, 2, 1, 3, 3 ];
93+
94+
var x = filled5dBy( shape, discreteUniform( -100, 100 ) );
95+
console.log( x );
96+
97+
var y = filled5dBy( shape, discreteUniform( -100, 100 ) );
98+
console.log( y );
99+
100+
var mask = filled5dBy( shape, bernoulli( 0.5 ) );
101+
console.log( mask );
102+
103+
var z = zeros5d( shape );
104+
console.log( z );
105+
106+
mskbinary5d( [ 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: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
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 filled5dBy = require( './../../../base/filled5d-by' );
31+
var zeros5d = require( './../../../base/zeros5d' );
32+
var numel = require( '@stdlib/ndarray/base/numel' );
33+
var pkg = require( './../package.json' ).name;
34+
var mskbinary5d = 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 = filled5dBy( shape, uniform( -100.0, 100.0 ) );
54+
y = filled5dBy( shape, uniform( -100.0, 100.0 ) );
55+
m = filled5dBy( shape, bernoulli( 0.5 ) );
56+
z = zeros5d( 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 i4;
74+
var i;
75+
76+
b.tic();
77+
for ( i = 0; i < b.iterations; i++ ) {
78+
mskbinary5d( arrays, shape, add );
79+
i4 = i % shape[ 0 ];
80+
i3 = i % shape[ 1 ];
81+
i2 = i % shape[ 2 ];
82+
i1 = i % shape[ 3 ];
83+
i0 = i % shape[ 4 ];
84+
if ( isnan( arrays[ 3 ][ i4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) {
85+
b.fail( 'should not return NaN' );
86+
}
87+
}
88+
b.toc();
89+
90+
i4 = i % shape[ 0 ];
91+
i3 = i % shape[ 1 ];
92+
i2 = i % shape[ 2 ];
93+
i1 = i % shape[ 3 ];
94+
i0 = i % shape[ 4 ];
95+
if ( isnan( arrays[ 3 ][ i4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) {
96+
b.fail( 'should not return NaN' );
97+
}
98+
b.pass( 'benchmark finished' );
99+
b.end();
100+
}
101+
}
102+
103+
104+
// MAIN //
105+
106+
/**
107+
* Main execution sequence.
108+
*
109+
* @private
110+
*/
111+
function main() {
112+
var min;
113+
var max;
114+
var sh;
115+
var N;
116+
var f;
117+
var i;
118+
119+
min = 1; // 10^min
120+
max = 6; // 10^max
121+
122+
for ( i = min; i <= max; i++ ) {
123+
N = floor( pow( pow( 10, i ), 1.0/5.0 ) );
124+
sh = [ N, N, N, N, N ];
125+
f = createBenchmark( sh );
126+
bench( pkg+'::equidimensional:size='+numel( sh ), f );
127+
}
128+
}
129+
130+
main();

base/mskbinary5d/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 five-dimensional nested input
4+
arrays according to elements in a five-dimensional nested mask array and
5+
assigns results to elements in a five-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, 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)