Skip to content

Commit a41b1cd

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

File tree

11 files changed

+1191
-3
lines changed

11 files changed

+1191
-3
lines changed

CHANGELOG.md

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,40 @@ A total of 3 issues were closed in this release:
290290

291291
<!-- /.package -->
292292

293+
<section class="package" id="array-base-mskunary5d-unreleased">
294+
295+
#### [@stdlib/array/base/mskunary5d](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/mskunary5d)
296+
297+
<details>
298+
299+
<section class="features">
300+
301+
##### Features
302+
303+
- [`b26d9d5`](https://github.com/stdlib-js/stdlib/commit/b26d9d5bd9e60a63ce017bbb470f0769b6dcc628) - add `array/base/mskunary5d` [(#3207)](https://github.com/stdlib-js/stdlib/pull/3207)
304+
305+
</section>
306+
307+
<!-- /.features -->
308+
309+
<section class="issues">
310+
311+
##### Closed Issues
312+
313+
This release closes the following issue:
314+
315+
[#3177](https://github.com/stdlib-js/stdlib/issues/3177)
316+
317+
</section>
318+
319+
<!-- /.issues -->
320+
321+
</details>
322+
323+
</section>
324+
325+
<!-- /.package -->
326+
293327
<section class="package" id="array-bool-unreleased">
294328

295329
#### [@stdlib/array/bool](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/bool)
@@ -412,9 +446,9 @@ A total of 2 issues were closed in this release:
412446

413447
### Closed Issues
414448

415-
A total of 5 issues were closed in this release:
449+
A total of 6 issues were closed in this release:
416450

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)
451+
[#3135](https://github.com/stdlib-js/stdlib/issues/3135), [#3138](https://github.com/stdlib-js/stdlib/issues/3138), [#3177](https://github.com/stdlib-js/stdlib/issues/3177), [#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)
418452

419453
</section>
420454

@@ -424,13 +458,14 @@ A total of 5 issues were closed in this release:
424458

425459
### Contributors
426460

427-
A total of 5 people contributed to this release. Thank you to the following contributors:
461+
A total of 6 people contributed to this release. Thank you to the following contributors:
428462

429463
- Aayush Khanna
430464
- Abhijit
431465
- Athan Reines
432466
- Philipp Burckhardt
433467
- Rylan Yang
468+
- Vinit Pandit
434469

435470
</section>
436471

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

443478
<details>
444479

480+
- [`b26d9d5`](https://github.com/stdlib-js/stdlib/commit/b26d9d5bd9e60a63ce017bbb470f0769b6dcc628) - **feat:** add `array/base/mskunary5d` [(#3207)](https://github.com/stdlib-js/stdlib/pull/3207) _(by Vinit Pandit, Athan Reines, Abhijit, stdlib-bot)_
445481
- [`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)_
446482
- [`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)_
447483
- [`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)_

base/mskunary5d/README.md

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

base/mskunary5d/docs/repl.txt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
{{alias}}( arrays, shape, fcn )
3+
Applies a unary callback to elements in a five-dimensional nested input
4+
array 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 one input nested array, an input nested
14+
mask array, and one output nested array.
15+
16+
shape: Array<integer>
17+
Array shape.
18+
19+
fcn: Function
20+
Unary callback.
21+
22+
Examples
23+
--------
24+
> var x = [ [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ] ];
25+
> var m = [ [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ] ];
26+
> var y = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ];
27+
> var shape = [ 1, 1, 1, 2, 2 ];
28+
> {{alias}}( [ x, m, y ], shape, {{alias:@stdlib/math/base/special/abs}} );
29+
> y
30+
[ [ [ [ [ 1.0, 0.0 ], [ 3.0, 4.0 ] ] ] ] ]
31+
32+
See Also
33+
--------
34+

0 commit comments

Comments
 (0)