Skip to content

Commit efc82b8

Browse files
committed
Auto-generated commit
1 parent fc7ea10 commit efc82b8

File tree

13 files changed

+60
-213
lines changed

13 files changed

+60
-213
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
<section class="release" id="unreleased">
66

7-
## Unreleased (2025-05-08)
7+
## Unreleased (2025-05-12)
88

99
<section class="bug-fixes">
1010

@@ -22,6 +22,7 @@
2222

2323
<details>
2424

25+
- [`dcfb648`](https://github.com/stdlib-js/stdlib/commit/dcfb6488ac9624b23ec546f7c54a2da0156c6695) - **refactor:** use generalized utility for resolving loop data _(by Athan Reines)_
2526
- [`3ce09af`](https://github.com/stdlib-js/stdlib/commit/3ce09af9819ae7dbaad178179264fc84c5db5690) - **fix:** ensure separate array instance for each memory layout _(by Athan Reines)_
2627

2728
</details>

CONTRIBUTORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ Utkarsh <http://utkarsh11105@gmail.com>
174174
Utkarsh Raj <rajutkarsh2505@gmail.com>
175175
UtkershBasnet <119008923+UtkershBasnet@users.noreply.github.com>
176176
Vaibhav Patel <98279986+noobCoderVP@users.noreply.github.com>
177+
Vara Rahul Rajana <123227543+rajanarahul93@users.noreply.github.com>
177178
Varad Gupta <varadgupta21@gmail.com>
178179
Vinit Pandit <106718914+MeastroZI@users.noreply.github.com>
179180
Vivek Maurya <vm8118134@gmail.com>

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,19 +130,23 @@ For all returned arrays, the first element corresponds to the innermost loop, an
130130

131131
## Examples
132132

133+
<!-- eslint-disable max-len -->
134+
133135
<!-- eslint no-undef: "error" -->
134136

135137
```javascript
136138
var array = require( '@stdlib/ndarray-array' );
137-
var loopOrder = require( '@stdlib/ndarray-base-binary-loop-interchange-order' );
139+
var getShape = require( '@stdlib/ndarray-shape' );
140+
var getStrides = require( '@stdlib/ndarray-strides' );
141+
var binaryLoopOrder = require( '@stdlib/ndarray-base-binary-loop-interchange-order' );
138142

139143
// Create ndarrays:
140144
var x = array( [ [ 1, 2 ], [ 3, 4 ] ] );
141145
var y = array( [ [ 5, 6 ], [ 7, 8 ] ] );
142146
var z = array( [ [ 0, 0 ], [ 0, 0 ] ] );
143147

144148
// Resolve loop interchange data:
145-
var o = loopOrder( x.shape, x.strides, y.strides, z.strides );
149+
var o = binaryLoopOrder( getShape( x ), getStrides( x ), getStrides( y ), getStrides( z ) );
146150
// returns {...}
147151

148152
console.log( o );

benchmark/benchmark.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,32 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench-harness' );
24-
var randu = require( '@stdlib/random-base-randu' );
2524
var isArray = require( '@stdlib/assert-is-array' );
2625
var shape2strides = require( '@stdlib/ndarray-base-shape2strides' );
2726
var pkg = require( './../package.json' ).name;
28-
var loopOrder = require( './../lib' );
27+
var binaryLoopOrder = require( './../lib' );
2928

3029

3130
// MAIN //
3231

3332
bench( pkg+'::row-major', function benchmark( b ) {
3433
var strides;
34+
var factors;
3535
var shape;
3636
var out;
3737
var i;
3838

3939
shape = [ 10, 10, 10 ];
4040
strides = shape2strides( shape, 'row-major' );
41+
factors = [
42+
-1,
43+
1
44+
];
4145

4246
b.tic();
4347
for ( i = 0; i < b.iterations; i++ ) {
44-
strides[ i%shape.length ] *= ( randu() < 0.5 ) ? -1 : 1;
45-
out = loopOrder( shape, strides, strides, strides );
48+
strides[ i%shape.length ] *= factors[ i%factors.length ];
49+
out = binaryLoopOrder( shape, strides, strides, strides );
4650
if ( typeof out !== 'object' ) {
4751
b.fail( 'should return an object' );
4852
}
@@ -57,17 +61,22 @@ bench( pkg+'::row-major', function benchmark( b ) {
5761

5862
bench( pkg+'::column-major', function benchmark( b ) {
5963
var strides;
64+
var factors;
6065
var shape;
6166
var out;
6267
var i;
6368

6469
shape = [ 10, 10, 10 ];
6570
strides = shape2strides( shape, 'column-major' );
71+
factors = [
72+
-1,
73+
1
74+
];
6675

6776
b.tic();
6877
for ( i = 0; i < b.iterations; i++ ) {
69-
strides[ i%shape.length ] *= ( randu() < 0.5 ) ? -1 : 1;
70-
out = loopOrder( shape, strides, strides, strides );
78+
strides[ i%shape.length ] *= factors[ i%factors.length ];
79+
out = binaryLoopOrder( shape, strides, strides, strides );
7180
if ( typeof out !== 'object' ) {
7281
b.fail( 'should return an object' );
7382
}

dist/index.js

Lines changed: 3 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/types/index.d.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ interface LoopOrderObject {
6767
*
6868
* - The function assumes that the input and output ndarrays have the same shape. Hence, loop interchange order should only be determined **after** broadcasting.
6969
*
70-
* @param sh - array dimensions
71-
* @param sx - first input array stride lengths
72-
* @param sy - second input array stride lengths
73-
* @param sz - output array stride lengths
70+
* @param shape - array dimensions
71+
* @param stridesX - first input array stride lengths
72+
* @param stridesY - second input array stride lengths
73+
* @param stridesZ - output array stride lengths
7474
* @returns loop interchange data
7575
*
7676
* @example
@@ -80,7 +80,7 @@ interface LoopOrderObject {
8080
* var sy = [ 24, 8, 1 ]; // row-major
8181
* var sz = [ 1, -2, 6 ]; // column-major
8282
*
83-
* var o = loopOrder( sh, sx, sy, sz );
83+
* var o = binaryLoopOrder( sh, sx, sy, sz );
8484
* // returns {...}
8585
*
8686
* var ssh = o.sh;

0 commit comments

Comments
 (0)