Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Jan 16, 2024
1 parent 95937ae commit a286170
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 4 deletions.
1 change: 1 addition & 0 deletions base/nullary-loop-interchange-order/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ The function returns an object having the following properties:

- **sh**: ordered dimensions.
- **sx**: array strides sorted in loop order.
- **idx**: dimension indices sorted in loop order.

For all returned arrays, the first element corresponds to the innermost loop, and the last element corresponds to the outermost loop.

Expand Down
4 changes: 4 additions & 0 deletions base/nullary-loop-interchange-order/docs/repl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- sh: ordered dimensions.
- sx: array strides sorted in loop order.
- idx: dimension indices sorted in loop order.

For all returned arrays, the first element corresponds to the innermost
loop, and the last element corresponds to the outermost loop.
Expand All @@ -29,6 +30,9 @@
out.sx: Array<integer>
Array strides sorted in loop order.

out.idx: Array<integer>
Dimension indices sorted in loop order.

Examples
--------
> var x = {{alias:@stdlib/ndarray/array}}( [ [ 1, 2 ], [ 3, 4 ] ] );
Expand Down
9 changes: 9 additions & 0 deletions base/nullary-loop-interchange-order/docs/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ interface LoopOrderObject {
* Array strides sorted in loop order.
*/
sx: Array<number>;

/**
* Dimension indices sorted in loop order.
*/
idx: Array<number>;
}

/**
Expand All @@ -46,6 +51,7 @@ interface LoopOrderObject {
*
* - **sh**: dimensions sorted in loop order.
* - **sx**: ndarray strides sorted in loop order.
* - **idx**: dimension indices sorted in loop order.
*
* - When iterating over the elements of a multi-dimensional array, accessing elements which are closer in memory can improve performance. To this end, loop interchange is a technique used in loop nest optimization to improve locality of reference and take advantage of CPU cache.
*
Expand All @@ -68,6 +74,9 @@ interface LoopOrderObject {
*
* var ssx = o.sx;
* // returns [ 1, 4, 12 ]
*
* var idx = o.idx;
* // returns [ 2, 1, 0 ]
*/
declare function nullaryLoopOrder( shape: ArrayLike<number>, stridesX: ArrayLike<number> ): LoopOrderObject;

Expand Down
3 changes: 3 additions & 0 deletions base/nullary-loop-interchange-order/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
*
* var ssx = o.sx;
* // returns [ 1, 4, 12 ]
*
* var idx = o.idx;
* // returns [ 2, 1, 0 ]
*/

// MODULES //
Expand Down
7 changes: 6 additions & 1 deletion base/nullary-loop-interchange-order/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ var sort2ins = require( './sort2ins.js' );
*
* - **sh**: dimensions sorted in loop order.
* - **sx**: ndarray strides sorted in loop order.
* - **idx**: dimension indices sorted in loop order.
*
* @param {NonNegativeIntegerArray} sh - array dimensions
* @param {IntegerArray} sx - array stride lengths
Expand All @@ -55,6 +56,9 @@ var sort2ins = require( './sort2ins.js' );
*
* var ssx = o.sx;
* // returns [ 1, 4, 12 ]
*
* var idx = o.idx;
* // returns [ 2, 1, 0 ]
*/
function loopOrder( sh, sx ) {
var idx;
Expand All @@ -71,7 +75,8 @@ function loopOrder( sh, sx ) {

return {
'sh': sh,
'sx': sx
'sx': sx,
'idx': idx
};
}

Expand Down
7 changes: 7 additions & 0 deletions base/nullary-loop-interchange-order/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ tape( 'the function returns loop interchange data (row-major)', function test( t
t.strictEqual( isArray( o.sx ), true, 'returns expected value' );
t.deepEqual( o.sx, [ 1, -2, 4 ], 'returns expected value' );

t.strictEqual( isArray( o.idx ), true, 'returns expected value' );
t.deepEqual( o.idx, [ 2, 1, 0 ], 'returns expected value' );

t.end();
});

Expand All @@ -72,12 +75,16 @@ tape( 'the function returns loop interchange data (column-major)', function test
t.strictEqual( isArray( o.sx ), true, 'returns expected value' );
t.deepEqual( o.sx, [ 1, -4, 8 ], 'returns expected value' );

t.strictEqual( isArray( o.idx ), true, 'returns expected value' );
t.deepEqual( o.idx, [ 0, 1, 2 ], 'returns expected value' );

t.end();
});

tape( 'if provided empty arrays, the function returns empty arrays', function test( t ) {
var o = loopOrder( [], [] );
t.deepEqual( o.sh, [], 'returns expected value' );
t.deepEqual( o.sx, [], 'returns expected value' );
t.deepEqual( o.idx, [], 'returns expected value' );
t.end();
});
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/index.js.map

Large diffs are not rendered by default.

0 comments on commit a286170

Please sign in to comment.