Skip to content

Commit 594003f

Browse files
committed
Auto-generated commit
1 parent ce4530b commit 594003f

File tree

11 files changed

+1294
-2
lines changed

11 files changed

+1294
-2
lines changed

CHANGELOG.md

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,40 @@ This release closes the following issue:
191191

192192
<!-- /.package -->
193193

194+
<section class="package" id="array-base-broadcasted-ternary5d-unreleased">
195+
196+
#### [@stdlib/array/base/broadcasted-ternary5d](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/broadcasted-ternary5d)
197+
198+
<details>
199+
200+
<section class="features">
201+
202+
##### Features
203+
204+
- [`982980c`](https://github.com/stdlib-js/stdlib/commit/982980c5e719d7ab8f227b9aea9507ab45b15957) - add `array/base/broadcasted-ternary5d` [(#3251)](https://github.com/stdlib-js/stdlib/pull/3251)
205+
206+
</section>
207+
208+
<!-- /.features -->
209+
210+
<section class="issues">
211+
212+
##### Closed Issues
213+
214+
This release closes the following issue:
215+
216+
[#3166](https://github.com/stdlib-js/stdlib/issues/3166)
217+
218+
</section>
219+
220+
<!-- /.issues -->
221+
222+
</details>
223+
224+
</section>
225+
226+
<!-- /.package -->
227+
194228
<section class="package" id="array-base-group-entries-unreleased">
195229

196230
#### [@stdlib/array/base/group-entries](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/group-entries)
@@ -559,9 +593,9 @@ A total of 12 issues were closed in this release:
559593

560594
### Closed Issues
561595

562-
A total of 19 issues were closed in this release:
596+
A total of 20 issues were closed in this release:
563597

564-
[#3135](https://github.com/stdlib-js/stdlib/issues/3135), [#3138](https://github.com/stdlib-js/stdlib/issues/3138), [#3140](https://github.com/stdlib-js/stdlib/issues/3140), [#3145](https://github.com/stdlib-js/stdlib/issues/3145), [#3146](https://github.com/stdlib-js/stdlib/issues/3146), [#3147](https://github.com/stdlib-js/stdlib/issues/3147), [#3149](https://github.com/stdlib-js/stdlib/issues/3149), [#3150](https://github.com/stdlib-js/stdlib/issues/3150), [#3151](https://github.com/stdlib-js/stdlib/issues/3151), [#3152](https://github.com/stdlib-js/stdlib/issues/3152), [#3155](https://github.com/stdlib-js/stdlib/issues/3155), [#3162](https://github.com/stdlib-js/stdlib/issues/3162), [#3164](https://github.com/stdlib-js/stdlib/issues/3164), [#3165](https://github.com/stdlib-js/stdlib/issues/3165), [#3176](https://github.com/stdlib-js/stdlib/issues/3176), [#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)
598+
[#3135](https://github.com/stdlib-js/stdlib/issues/3135), [#3138](https://github.com/stdlib-js/stdlib/issues/3138), [#3140](https://github.com/stdlib-js/stdlib/issues/3140), [#3145](https://github.com/stdlib-js/stdlib/issues/3145), [#3146](https://github.com/stdlib-js/stdlib/issues/3146), [#3147](https://github.com/stdlib-js/stdlib/issues/3147), [#3149](https://github.com/stdlib-js/stdlib/issues/3149), [#3150](https://github.com/stdlib-js/stdlib/issues/3150), [#3151](https://github.com/stdlib-js/stdlib/issues/3151), [#3152](https://github.com/stdlib-js/stdlib/issues/3152), [#3155](https://github.com/stdlib-js/stdlib/issues/3155), [#3162](https://github.com/stdlib-js/stdlib/issues/3162), [#3164](https://github.com/stdlib-js/stdlib/issues/3164), [#3165](https://github.com/stdlib-js/stdlib/issues/3165), [#3166](https://github.com/stdlib-js/stdlib/issues/3166), [#3176](https://github.com/stdlib-js/stdlib/issues/3176), [#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)
565599

566600
</section>
567601

@@ -594,6 +628,7 @@ A total of 10 people contributed to this release. Thank you to the following con
594628

595629
<details>
596630

631+
- [`982980c`](https://github.com/stdlib-js/stdlib/commit/982980c5e719d7ab8f227b9aea9507ab45b15957) - **feat:** add `array/base/broadcasted-ternary5d` [(#3251)](https://github.com/stdlib-js/stdlib/pull/3251) _(by Vinit Pandit, Athan Reines)_
597632
- [`bf5643f`](https://github.com/stdlib-js/stdlib/commit/bf5643fb1a3f32a60903d8e210f71571e609119f) - **docs:** update related packages sections [(#3404)](https://github.com/stdlib-js/stdlib/pull/3404) _(by stdlib-bot)_
598633
- [`ac06419`](https://github.com/stdlib-js/stdlib/commit/ac06419c2a8358dfd80818823f571077eb58958e) - **docs:** update related packages sections [(#3387)](https://github.com/stdlib-js/stdlib/pull/3387) _(by stdlib-bot)_
599634
- [`1c56b73`](https://github.com/stdlib-js/stdlib/commit/1c56b737ec018cc818cebf19e5c7947fa684e126) - **docs:** update related packages sections [(#3380)](https://github.com/stdlib-js/stdlib/pull/3380) _(by stdlib-bot)_
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
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+
# bternary5d
22+
23+
> Apply a ternary callback to elements in three [broadcasted][@stdlib/array/base/broadcast-array] nested input arrays 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 bternary5d = require( '@stdlib/array/base/broadcasted-ternary5d' );
37+
```
38+
39+
#### bternary5d( arrays, shapes, fcn )
40+
41+
Applies a ternary callback to elements in three [broadcasted][@stdlib/array/base/broadcast-array] nested input arrays and assigns results to elements in a five-dimensional nested output array.
42+
43+
```javascript
44+
var add = require( '@stdlib/math/base/ops/add3' );
45+
var zeros5d = require( '@stdlib/array/base/zeros5d' );
46+
47+
var x = [ [ [ 1.0, 2.0 ] ] ];
48+
var y = [ [ [ 3.0 ], [ 4.0 ] ] ];
49+
var z = [ [ [ [ 4.0, 5.0 ] ], [ [ 4.0, 5.0 ] ] ] ];
50+
var out = zeros5d( [ 1, 1, 2, 2 ] );
51+
52+
var shapes = [
53+
[ 1, 1, 2 ],
54+
[ 1, 2, 1 ],
55+
[ 1, 2, 1, 2 ],
56+
[ 1, 1, 2, 2, 2 ]
57+
];
58+
59+
bternary5d( [ x, y, z, out ], shapes, add );
60+
// out => [ [ [ [ [ 8.0, 10.0 ], [ 9.0, 11.0 ] ], [ [ 8.0, 10.0 ], [ 9.0, 11.0 ] ] ] ] ]
61+
```
62+
63+
The function accepts the following arguments:
64+
65+
- **arrays**: array-like object containing three input nested arrays and one output nested array.
66+
- **shapes**: array shapes.
67+
- **fcn**: ternary function to apply.
68+
69+
</section>
70+
71+
<!-- /.usage -->
72+
73+
<section class="notes">
74+
75+
## Notes
76+
77+
- The input and output array shapes must be broadcast [compatible][@stdlib/ndarray/base/broadcast-shapes].
78+
79+
</section>
80+
81+
<!-- /.notes -->
82+
83+
<section class="examples">
84+
85+
## Examples
86+
87+
<!-- eslint no-undef: "error" -->
88+
89+
```javascript
90+
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory;
91+
var filled5dBy = require( '@stdlib/array/base/filled5d-by' );
92+
var zeros5d = require( '@stdlib/array/base/zeros5d' );
93+
var add = require( '@stdlib/math/base/ops/add3' );
94+
var bternary5d = require( '@stdlib/array/base/broadcasted-ternary5d' );
95+
96+
var shapes = [
97+
[ 1, 1, 1, 1, 3 ],
98+
[ 1, 1, 3, 1, 1 ],
99+
[ 1, 1, 1, 3, 1 ],
100+
[ 1, 1, 3, 3, 3 ]
101+
];
102+
103+
var x = filled5dBy( shapes[ 0 ], discreteUniform( -100, 100 ) );
104+
console.log( x );
105+
106+
var y = filled5dBy( shapes[ 1 ], discreteUniform( -100, 100 ) );
107+
console.log( y );
108+
109+
var z = filled5dBy( shapes[ 2 ], discreteUniform( -100, 100 ) );
110+
console.log( z );
111+
112+
var out = zeros5d( shapes[ 3 ] );
113+
console.log( out );
114+
115+
bternary5d( [ x, y, z, out ], shapes, add );
116+
console.log( out );
117+
```
118+
119+
</section>
120+
121+
<!-- /.examples -->
122+
123+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
124+
125+
<section class="related">
126+
127+
</section>
128+
129+
<!-- /.related -->
130+
131+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
132+
133+
<section class="links">
134+
135+
[@stdlib/array/base/broadcast-array]: https://github.com/stdlib-js/array/tree/main/base/broadcast-array
136+
137+
[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes
138+
139+
</section>
140+
141+
<!-- /.links -->
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
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 isnan = require( '@stdlib/math/base/assert/is-nan' );
26+
var pow = require( '@stdlib/math/base/special/pow' );
27+
var floor = require( '@stdlib/math/base/special/floor' );
28+
var add = require( '@stdlib/math/base/ops/add3' );
29+
var filled5dBy = require( './../../../base/filled5d-by' );
30+
var zeros5d = require( './../../../base/zeros5d' );
31+
var numel = require( '@stdlib/ndarray/base/numel' );
32+
var pkg = require( './../package.json' ).name;
33+
var bternary5d = require( './../lib' );
34+
35+
36+
// FUNCTIONS //
37+
38+
/**
39+
* Creates a benchmark function.
40+
*
41+
* @private
42+
* @param {PositiveIntegerArray} shape - output array shape
43+
* @returns {Function} benchmark function
44+
*/
45+
function createBenchmark( shape ) {
46+
var arrays;
47+
var shapes;
48+
var x;
49+
var y;
50+
var z;
51+
var w;
52+
53+
shapes = [
54+
[ shape[ 0 ], 1, 1, 1, 1 ],
55+
[ 1, 1, 1, 1, shape[ 1 ] ],
56+
[ 1, 1, shape[ 2 ], 1, 1 ],
57+
shape
58+
];
59+
x = filled5dBy( shapes[ 0 ], uniform( -100.0, 100.0 ) );
60+
y = filled5dBy( shapes[ 1 ], uniform( -100.0, 100.0 ) );
61+
z = filled5dBy( shapes[ 2 ], uniform( -100.0, 100.0 ) );
62+
w = zeros5d( shapes[ 3 ] );
63+
64+
arrays = [ x, y, z, w ];
65+
66+
return benchmark;
67+
68+
/**
69+
* Benchmark function.
70+
*
71+
* @private
72+
* @param {Benchmark} b - benchmark instance
73+
*/
74+
function benchmark( b ) {
75+
var i0;
76+
var i1;
77+
var i2;
78+
var i3;
79+
var i4;
80+
var i;
81+
82+
b.tic();
83+
for ( i = 0; i < b.iterations; i++ ) {
84+
bternary5d( arrays, shapes, add );
85+
i4 = i % shapes[ 1 ][ 0 ];
86+
i3 = i % shapes[ 1 ][ 1 ];
87+
i2 = i % shapes[ 1 ][ 2 ];
88+
i1 = i % shapes[ 1 ][ 3 ];
89+
i0 = i % shapes[ 1 ][ 4 ];
90+
if ( isnan( arrays[ 3 ][ i4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) {
91+
b.fail( 'should not return NaN' );
92+
}
93+
}
94+
b.toc();
95+
96+
i4 = i % shapes[ 1 ][ 0 ];
97+
i3 = i % shapes[ 1 ][ 1 ];
98+
i2 = i % shapes[ 1 ][ 2 ];
99+
i1 = i % shapes[ 1 ][ 3 ];
100+
i0 = i % shapes[ 1 ][ 4 ];
101+
if ( isnan(arrays[ 3 ][ i4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) {
102+
b.fail( 'should not return NaN' );
103+
}
104+
b.pass( 'benchmark finished' );
105+
b.end();
106+
}
107+
}
108+
109+
110+
// MAIN //
111+
112+
/**
113+
* Main execution sequence.
114+
*
115+
* @private
116+
*/
117+
function main() {
118+
var min;
119+
var max;
120+
var sh;
121+
var N;
122+
var f;
123+
var i;
124+
125+
min = 1; // 10^min
126+
max = 6; // 10^max
127+
128+
for ( i = min; i <= max; i++ ) {
129+
N = floor( pow( pow( 10, i ), 1.0 / 5.0 ) );
130+
sh = [ N, N, N, N, N ];
131+
f = createBenchmark( sh );
132+
bench( pkg + '::equidimensional:size=' + numel( sh ), f );
133+
}
134+
}
135+
136+
main();
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
{{alias}}( arrays, shapes, fcn )
3+
Applies a ternary callback to elements in three broadcasted input arrays and
4+
assigns results to elements in a five-dimensional nested output array.
5+
6+
Parameters
7+
----------
8+
arrays: ArrayLikeObject
9+
Array-like object containing three input nested arrays and one output
10+
nested array.
11+
12+
shapes: Array<Array<integer>>
13+
Array shapes.
14+
15+
fcn: Function
16+
Ternary callback.
17+
18+
Examples
19+
--------
20+
> function fcn( x, y, z ) { return x + y + z };
21+
> var x = [ 1.0 ];
22+
> var y = [ [ 2.0, 2.0 ], [ 3.0, 3.0 ] ];
23+
> var z = [ [ [ [ [ 2.0 ], [ 3.0 ] ] ] ] ];
24+
> var out = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ];
25+
> var shapes = [ [ 1 ], [ 2, 2 ], [ 1, 1, 1, 2, 1 ], [ 1, 1, 1, 2, 2 ] ];
26+
> {{alias}}( [ x, y, z, out ], shapes, fcn );
27+
> out
28+
[ [ [ [ [ 5.0, 5.0 ], [ 7.0, 7.0 ] ] ] ] ]
29+
30+
See Also
31+
--------
32+

0 commit comments

Comments
 (0)