Skip to content

Commit 09c9c5e

Browse files
committed
Auto-generated commit
1 parent 3a17e22 commit 09c9c5e

File tree

11 files changed

+1014
-3
lines changed

11 files changed

+1014
-3
lines changed

CHANGELOG.md

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,40 @@
254254

255255
<!-- /.package -->
256256

257+
<section class="package" id="array-base-msk-unreleased">
258+
259+
#### [@stdlib/array/base/msk](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/msk)
260+
261+
<details>
262+
263+
<section class="features">
264+
265+
##### Features
266+
267+
- [`c328fc5`](https://github.com/stdlib-js/stdlib/commit/c328fc515fc925ee717ed9cd844cca83a61da806) - add `array/base/mskbinary3d` [(#3193)](https://github.com/stdlib-js/stdlib/pull/3193)
268+
269+
</section>
270+
271+
<!-- /.features -->
272+
273+
<section class="issues">
274+
275+
##### Closed Issues
276+
277+
This release closes the following issue:
278+
279+
[#3178](https://github.com/stdlib-js/stdlib/issues/3178)
280+
281+
</section>
282+
283+
<!-- /.issues -->
284+
285+
</details>
286+
287+
</section>
288+
289+
<!-- /.package -->
290+
257291
<section class="package" id="array-bool-unreleased">
258292

259293
#### [@stdlib/array/bool](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/bool)
@@ -375,9 +409,9 @@ This release closes the following issue:
375409

376410
### Closed Issues
377411

378-
This release closes the following issue:
412+
A total of 2 issues were closed in this release:
379413

380-
[#3135](https://github.com/stdlib-js/stdlib/issues/3135)
414+
[#3135](https://github.com/stdlib-js/stdlib/issues/3135), [#3178](https://github.com/stdlib-js/stdlib/issues/3178)
381415

382416
</section>
383417

@@ -387,11 +421,12 @@ This release closes the following issue:
387421

388422
### Contributors
389423

390-
A total of 3 people contributed to this release. Thank you to the following contributors:
424+
A total of 4 people contributed to this release. Thank you to the following contributors:
391425

392426
- Aayush Khanna
393427
- Athan Reines
394428
- Philipp Burckhardt
429+
- Rylan Yang
395430

396431
</section>
397432

@@ -403,6 +438,7 @@ A total of 3 people contributed to this release. Thank you to the following cont
403438

404439
<details>
405440

441+
- [`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)_
406442
- [`9ba0dbd`](https://github.com/stdlib-js/stdlib/commit/9ba0dbd839707695a05fda5d4f50d67c5aba52f7) - **chore:** use relative paths to load main package export _(by Philipp Burckhardt)_
407443
- [`6c020d3`](https://github.com/stdlib-js/stdlib/commit/6c020d33665c4aec232196fd86214b296ddc7d36) - **chore:** use relative paths to load package.json file _(by Philipp Burckhardt)_
408444
- [`b6a2b0b`](https://github.com/stdlib-js/stdlib/commit/b6a2b0b27dc8cc1e9fc02d9679a3ce468cf49b9d) - **docs:** update namespace table of contents [(#3192)](https://github.com/stdlib-js/stdlib/pull/3192) _(by stdlib-bot, Philipp Burckhardt)_

base/mskbinary3d/README.md

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
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+
# mskbinary3d
22+
23+
> Apply a binary callback to elements in two three-dimensional nested input arrays according to elements in a three-dimensional nested mask array and assign results to elements in a three-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 mskbinary3d = require( '@stdlib/array/base/mskbinary3d' );
37+
```
38+
39+
#### mskbinary3d( arrays, shape, fcn )
40+
41+
Applies a binary callback to elements in two three-dimensional nested input arrays according to elements in a three-dimensional nested mask array and assigns results to elements in a three-dimensional nested output array.
42+
43+
```javascript
44+
var add = require( '@stdlib/math/base/ops/add' );
45+
var zeros3d = require( '@stdlib/array/base/zeros3d' );
46+
47+
var x = [
48+
[ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ],
49+
[ [ 5.0, 6.0 ], [ 7.0, 8.0 ] ]
50+
];
51+
var z = zeros3d( [ 2, 2, 2 ] );
52+
53+
var mask = [
54+
[ [ 0, 1 ], [ 0, 0 ] ],
55+
[ [ 1, 0 ], [ 0, 1 ] ]
56+
];
57+
58+
var shape = [ 2, 2, 2 ];
59+
60+
mskbinary3d( [ x, x, mask, z ], shape, add );
61+
// z => [ [ [ 2.0, 0.0 ], [ 6.0, 8.0 ] ], [ [ 0.0, 12.0 ], [ 14.0, 0.0 ] ] ]
62+
```
63+
64+
The function accepts the following arguments:
65+
66+
- **arrays**: array-like object containing two input nested arrays, an input nested mask array, and one output nested array.
67+
- **shape**: array shape.
68+
- **fcn**: binary function to apply.
69+
70+
</section>
71+
72+
<!-- /.usage -->
73+
74+
<section class="notes">
75+
76+
## Notes
77+
78+
- The function assumes that the input and output arrays have the same shape.
79+
80+
</section>
81+
82+
<!-- /.notes -->
83+
84+
<section class="examples">
85+
86+
## Examples
87+
88+
<!-- eslint no-undef: "error" -->
89+
90+
```javascript
91+
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory;
92+
var bernoulli = require( '@stdlib/random/base/bernoulli' ).factory;
93+
var filled3dBy = require( '@stdlib/array/base/filled3d-by' );
94+
var zeros3d = require( '@stdlib/array/base/zeros3d' );
95+
var add = require( '@stdlib/math/base/ops/add' );
96+
var mskbinary3d = require( '@stdlib/array/base/mskbinary3d' );
97+
98+
var shape = [ 3, 3, 3 ];
99+
100+
var x = filled3dBy( shape, discreteUniform( -100, 100 ) );
101+
console.log( x );
102+
103+
var y = filled3dBy( shape, discreteUniform( -100, 100 ) );
104+
console.log( y );
105+
106+
var mask = filled3dBy( shape, bernoulli( 0.5 ) );
107+
console.log( mask );
108+
109+
var z = zeros3d( shape );
110+
console.log( z );
111+
112+
mskbinary3d( [ x, y, mask, z ], shape, add );
113+
console.log( z );
114+
```
115+
116+
</section>
117+
118+
<!-- /.examples -->
119+
120+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
121+
122+
<section class="related">
123+
124+
</section>
125+
126+
<!-- /.related -->
127+
128+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
129+
130+
<section class="links">
131+
132+
</section>
133+
134+
<!-- /.links -->
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
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 filled3dBy = require( './../../../base/filled3d-by' );
31+
var zeros3d = require( './../../../base/zeros3d' );
32+
var numel = require( '@stdlib/ndarray/base/numel' );
33+
var pkg = require( './../package.json' ).name;
34+
var mskbinary3d = 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 = filled3dBy( shape, uniform( -100.0, 100.0 ) );
54+
y = filled3dBy( shape, uniform( -100.0, 100.0 ) );
55+
m = filled3dBy( shape, bernoulli( 0.5 ) );
56+
z = zeros3d( 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 i;
73+
74+
b.tic();
75+
for ( i = 0; i < b.iterations; i++ ) {
76+
mskbinary3d( arrays, shape, add );
77+
i2 = i % shape[ 0 ];
78+
i1 = i % shape[ 1 ];
79+
i0 = i % shape[ 2 ];
80+
if ( isnan( arrays[ 3 ][ i2 ][ i1 ][ i0 ] ) ) {
81+
b.fail( 'should not return NaN' );
82+
}
83+
}
84+
b.toc();
85+
86+
i2 = i % shape[ 0 ];
87+
i1 = i % shape[ 1 ];
88+
i0 = i % shape[ 2 ];
89+
if ( isnan( arrays[ 3 ][ i2 ][ i1 ][ i0 ] ) ) {
90+
b.fail( 'should not return NaN' );
91+
}
92+
b.pass( 'benchmark finished' );
93+
b.end();
94+
}
95+
}
96+
97+
98+
// MAIN //
99+
100+
/**
101+
* Main execution sequence.
102+
*
103+
* @private
104+
*/
105+
function main() {
106+
var min;
107+
var max;
108+
var sh;
109+
var N;
110+
var f;
111+
var i;
112+
113+
min = 1; // 10^min
114+
max = 6; // 10^max
115+
116+
for ( i = min; i <= max; i++ ) {
117+
N = floor( pow( pow( 10, i ), 1.0/3.0 ) );
118+
sh = [ N, N, N ];
119+
f = createBenchmark( sh );
120+
bench( pkg+'::equidimensional:size='+numel( sh ), f );
121+
}
122+
}
123+
124+
main();

base/mskbinary3d/docs/repl.txt

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
{{alias}}( arrays, shape, fcn )
3+
Applies a binary callback to elements in two three-dimensional nested input
4+
arrays according to elements in a three-dimensional nested mask array and
5+
assigns results to elements in a three-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 = [
25+
... [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ],
26+
... [ [ 5.0, 6.0 ], [ 7.0, 8.0 ] ]
27+
... ];
28+
> var y = [
29+
... [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ],
30+
... [ [ 5.0, 6.0 ], [ 7.0, 8.0 ] ]
31+
... ];
32+
> var m = [
33+
... [ [ 0, 1 ], [ 0, 0 ] ],
34+
... [ [ 1, 0 ], [ 0, 1 ] ]
35+
... ];
36+
> var z = [
37+
... [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ],
38+
... [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]
39+
... ];
40+
> var shape = [ 2, 2, 2 ];
41+
> {{alias}}( [ x, y, m, z ], shape, {{alias:@stdlib/math/base/ops/add}} );
42+
> z
43+
[ [ [ 2.0, 0.0 ], [ 6.0, 8.0 ] ], [ [ 0.0, 12.0 ], [ 14.0, 0.0 ] ] ]
44+
45+
See Also
46+
--------

0 commit comments

Comments
 (0)