Skip to content

Commit 6d77e6a

Browse files
authored
Merge branch 'develop' into endian-indexOf
Signed-off-by: Athan <[email protected]>
2 parents 1cc23a6 + 5c40302 commit 6d77e6a

File tree

119 files changed

+5507
-554
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+5507
-554
lines changed

.github/workflows/lint_random_files.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ jobs:
193193
lint_filenames="${root}/lib/node_modules/@stdlib/_tools/lint/filenames/bin/cli"
194194
195195
# Lint filenames:
196-
echo "${{ steps.random-files.outputs.files }}" | tr ',' '\n' || "${lint_filenames}"
196+
echo "${{ steps.random-files.outputs.files }}" | tr ',' '\n' | "${lint_filenames}"
197197
198198
# Lint Markdown files:
199199
- name: 'Lint Markdown files'
@@ -345,6 +345,7 @@ jobs:
345345
346346
# Lint C files:
347347
- name: 'Lint C files'
348+
id: lint-c
348349
if: ( github.event.inputs.c != 'false' ) && ( success() || failure() )
349350
run: |
350351
# Determine root directory:
@@ -388,7 +389,7 @@ jobs:
388389
389390
# Create sub-issue for C linting failures:
390391
- name: 'Create sub-issue for C lint failures'
391-
if: ( github.event.inputs.c != 'false' ) && failure() && contains(steps.*.outcome, 'failure') && contains(job.steps.*.name, 'Lint C files')
392+
if: ( github.event.inputs.c != 'false' ) && failure() && contains(steps.*.outcome, 'failure') && contains(steps.lint-c.outcome, 'failure')
392393
env:
393394
GITHUB_TOKEN: ${{ secrets.STDLIB_BOT_GITHUB_TOKEN }}
394395
run: |

.github/workflows/run_tests_coverage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#/
1818

1919
# Workflow name:
20-
name: run_tests_coverage.yml
20+
name: run_tests_coverage
2121

2222
# Workflow triggers:
2323
on:

.mailmap

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
1212
Aayush Khanna <[email protected]> aayush0325
1313

14+
15+
Abhijit Raut <[email protected]> AbhijitRaut04
16+
1417
1518
Adarsh Palaskar <[email protected]> adarshpalaskar1
1619

@@ -86,6 +89,9 @@ Matt Cochrane <[email protected]> <[email protected]>
8689

8790
Mihir Pandit <[email protected]> MSP20086
8891

92+
93+
Mohammad Kaif <[email protected]> Kaif987
94+
8995
9096
Muhammad Haris <[email protected]> headlessNode
9197

CONTRIBUTORS

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
# Contributors listed in alphabetical order.
44

55
Aayush Khanna <[email protected]>
6-
7-
AbhijitRaut04 <[email protected]>
6+
Abhijit Raut <[email protected]>
87
Adarsh Palaskar <[email protected]>
98
Aditya Sapra <[email protected]>
109
AgPriyanshu18 <[email protected]>
@@ -45,18 +44,18 @@ Joey Reed <[email protected]>
4544
Jordan Gallivan <[email protected]>
4645
Joris Labie <[email protected]>
4746
Justin Dennison <[email protected]>
48-
Kaif Mohd <[email protected]>
4947
Karthik Prakash <[email protected]>
5048
5149
Kohantika Nath <[email protected]>
5250
Krishnendu Das <[email protected]>
51+
Kshitij-Dale <[email protected]>
5352
5453
Manik Sharma <[email protected]>
5554
Marcus Fantham <[email protected]>
5655
Matt Cochrane <[email protected]>
5756
Mihir Pandit <[email protected]>
5857
Milan Raj <[email protected]>
59-
Mohammad Kaif <[email protected].com>
58+
Mohammad Kaif <mdkaifprofession@gmail.com>
6059
Momtchil Momtchev <[email protected]>
6160
Muhammad Haris <[email protected]>
6261
Naresh Jagadeesan <[email protected]>
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+
# bternary4d
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 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 bternary4d = require( '@stdlib/array/base/broadcasted-ternary4d' );
37+
```
38+
39+
#### bternary4d( 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 four-dimensional nested output array.
42+
43+
```javascript
44+
var add = require( '@stdlib/math/base/ops/add3' );
45+
var zeros4d = require( '@stdlib/array/base/zeros4d' );
46+
47+
var x = [ [ [ 1.0 ] ] ];
48+
var y = [ [ [ 2.0, 3.0 ] ] ];
49+
var z = [ [ [ [ 4.0, 5.0 ] ] ] ];
50+
var out = zeros4d( [ 1, 1, 2, 2 ] );
51+
52+
var shapes = [
53+
[ 1, 1, 1 ],
54+
[ 1, 1, 2 ],
55+
[ 1, 1, 1, 2 ],
56+
[ 1, 1, 2, 2 ]
57+
];
58+
59+
bternary4d( [ x, y, z, out ], shapes, add );
60+
// out => [ [ [ [ 7.0, 9.0 ], [ 7.0, 9.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 filled4dBy = require( '@stdlib/array/base/filled4d-by' );
92+
var zeros4d = require( '@stdlib/array/base/zeros4d' );
93+
var add = require( '@stdlib/math/base/ops/add3' );
94+
var bternary4d = require( '@stdlib/array/base/broadcasted-ternary4d' );
95+
96+
var shapes = [
97+
[ 1, 1, 1, 3 ],
98+
[ 1, 1, 3, 1 ],
99+
[ 1, 1, 3 ],
100+
[ 1, 1, 3, 3 ]
101+
];
102+
103+
var x = filled4dBy( shapes[ 0 ], discreteUniform( -100, 100 ) );
104+
console.log( x );
105+
106+
var y = filled4dBy( shapes[ 1 ], discreteUniform( -100, 100 ) );
107+
console.log( y );
108+
109+
var z = filled4dBy( shapes[ 2 ], discreteUniform( -100, 100 ) );
110+
console.log( z );
111+
112+
var out = zeros4d( shapes[ 3 ] );
113+
console.log( out );
114+
115+
bternary4d( [ 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/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/broadcast-array
136+
137+
[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/broadcast-shapes
138+
139+
</section>
140+
141+
<!-- /.links -->
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
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 filled4dBy = require( '@stdlib/array/base/filled4d-by' );
30+
var zeros4d = require( '@stdlib/array/base/zeros4d' );
31+
var numel = require( '@stdlib/ndarray/base/numel' );
32+
var pkg = require( './../package.json' ).name;
33+
var bternary4d = 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+
[ 1, 1, shape[ 2 ], 1 ],
55+
[ shape[ 0 ], 1, 1, 1 ],
56+
[ 1, shape[ 1 ], 1, 1 ],
57+
shape
58+
];
59+
x = filled4dBy( shapes[ 0 ], uniform( -100.0, 100.0 ) );
60+
y = filled4dBy( shapes[ 1 ], uniform( -100.0, 100.0 ) );
61+
z = filled4dBy( shapes[ 2 ], uniform(-100.0, 100.0 ) );
62+
w = zeros4d( 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 i;
80+
81+
b.tic();
82+
for ( i = 0; i < b.iterations; i++ ) {
83+
bternary4d( arrays, shapes, add );
84+
i3 = i % shapes[ 1 ][ 0 ];
85+
i2 = i % shapes[ 1 ][ 1 ];
86+
i1 = i % shapes[ 1 ][ 2 ];
87+
i0 = i % shapes[ 1 ][ 3 ];
88+
if ( isnan( arrays[ 3 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) {
89+
b.fail( 'should not return NaN' );
90+
}
91+
}
92+
b.toc();
93+
94+
i3 = i % shapes[ 1 ][ 0 ];
95+
i2 = i % shapes[ 1 ][ 1 ];
96+
i1 = i % shapes[ 1 ][ 2 ];
97+
i0 = i % shapes[ 1 ][ 3 ];
98+
if ( isnan( arrays[ 3 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) {
99+
b.fail( 'should not return NaN' );
100+
}
101+
b.pass( 'benchmark finished' );
102+
b.end();
103+
}
104+
}
105+
106+
107+
// MAIN //
108+
109+
/**
110+
* Main execution sequence.
111+
*
112+
* @private
113+
*/
114+
function main() {
115+
var min;
116+
var max;
117+
var sh;
118+
var N;
119+
var f;
120+
var i;
121+
122+
min = 1; // 10^min
123+
max = 6; // 10^max
124+
125+
for ( i = min; i <= max; i++ ) {
126+
N = floor( pow( pow( 10, i ), 1.0 / 4.0 ) );
127+
sh = [ N, N, N, N ];
128+
f = createBenchmark( sh );
129+
bench( pkg + '::equidimensional:size=' + numel( sh ), f );
130+
}
131+
}
132+
133+
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 four-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, 3.0 ] ] ];
23+
> var z = [ [ [ [ 4.0, 5.0 ] ] ] ];
24+
> var out = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ];
25+
> var shapes =[ [ 1, 1, 1 ], [ 1, 1, 2 ], [ 1, 1, 1, 2 ], [ 1, 1, 2, 2 ] ];
26+
> {{alias}}( [ x, y, z, out ], shapes, fcn );
27+
> out
28+
[ [ [ [ 7.0, 9.0 ], [ 7.0, 9.0 ] ] ] ]
29+
30+
See Also
31+
--------
32+

0 commit comments

Comments
 (0)