Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ The function returns an object having the following properties:
- **sx**: first input array strides sorted in loop order.
- **sy**: second input array strides sorted in loop order.
- **sz**: output 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
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- sx: first input array strides sorted in loop order.
- sy: second input array strides sorted in loop order.
- sz: output 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 Expand Up @@ -46,6 +47,9 @@
out.sz: Array<integer>
Output 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
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ interface LoopOrderObject {
* Output array strides sorted in loop order.
*/
sz: Array<number>;

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

/**
Expand All @@ -58,6 +63,7 @@ interface LoopOrderObject {
* - **sx**: first input ndarray strides sorted in loop order.
* - **sy**: second input ndarray strides sorted in loop order.
* - **sz**: output 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 Down Expand Up @@ -94,6 +100,9 @@ interface LoopOrderObject {
*
* var ssz = o.sz;
* // returns [ 6, -2, 1 ]
*
* var idx = o.idx;
* // returns [ 2, 1, 0 ]
*/
declare function binaryLoopOrder( shape: ArrayLike<number>, stridesX: ArrayLike<number>, stridesY: ArrayLike<number>, stridesZ: ArrayLike<number> ): LoopOrderObject;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
*
* var ssz = o.sz;
* // returns [ 6, -2, 1 ]
*
* var idx = o.idx;
* // returns [ 2, 1, 0 ]
*/

// MODULES //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ var loopOrder = require( '@stdlib/ndarray/base/loop-interchange-order' );
* - **sx**: first input ndarray strides sorted in loop order.
* - **sy**: second input ndarray strides sorted in loop order.
* - **sz**: output ndarray strides sorted in loop order.
* - **idx**: dimension indices sorted in loop order.
*
* @param {NonNegativeIntegerArray} sh - array dimensions
* @param {IntegerArray} sx - first input array stride lengths
Expand Down Expand Up @@ -64,14 +65,18 @@ var loopOrder = require( '@stdlib/ndarray/base/loop-interchange-order' );
*
* var ssz = o.sz;
* // returns [ 6, -2, 1 ]
*
* var idx = o.idx;
* // returns [ 2, 1, 0 ]
*/
function binaryLoopOrder( sh, sx, sy, sz ) {
var tmp = loopOrder( sh, [ sx, sy, sz ] );
return {
'sh': tmp[ 0 ],
'sx': tmp[ 1 ],
'sy': tmp[ 2 ],
'sz': tmp[ 3 ]
'sz': tmp[ 3 ],
'idx': tmp[ 4 ]
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ tape( 'the function returns loop interchange data (row-major)', function test( t
t.strictEqual( isArray( o.sz ), true, 'returns expected value' );
t.deepEqual( o.sz, [ -2, 4, -8 ], '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 Down Expand Up @@ -96,6 +99,9 @@ tape( 'the function returns loop interchange data (column-major)', function test
t.strictEqual( isArray( o.sz ), true, 'returns expected value' );
t.deepEqual( o.sz, [ -2, 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();
});

Expand Down Expand Up @@ -129,6 +135,9 @@ tape( 'the function returns loop interchange data (mixed order)', function test(
t.strictEqual( isArray( o.sz ), true, 'returns expected value' );
t.deepEqual( o.sz, [ -2, 4, -8 ], '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 Down Expand Up @@ -162,6 +171,9 @@ tape( 'the function returns loop interchange data (mostly disorganized)', functi
t.strictEqual( isArray( o.sz ), true, 'returns expected value' );
t.deepEqual( o.sz, [ 4, -2, -8 ], '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 Down Expand Up @@ -195,6 +207,9 @@ tape( 'the function returns loop interchange data (all disorganized)', function
t.strictEqual( isArray( o.sz ), true, 'returns expected value' );
t.deepEqual( o.sz, [ 4, -8, -2 ], 'returns expected value' );

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

t.end();
});

Expand All @@ -204,5 +219,6 @@ tape( 'if provided empty arrays, the function returns empty arrays', function te
t.deepEqual( o.sx, [], 'returns expected value' );
t.deepEqual( o.sy, [], 'returns expected value' );
t.deepEqual( o.sz, [], 'returns expected value' );
t.deepEqual( o.idx, [], 'returns expected value' );
t.end();
});
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,14 @@ var o = loopOrder( shape, [ stridesX, stridesY, stridesZ ] );
The function returns an array having the following elements:

```text
[ <shape>, ...<strides> ]
[ <shape>, ...<strides>, <idx> ]
```

where

- **shape**: dimensions sorted in loop order.
- **...strides**: strides for each respective ndarray 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
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@

The function returns an array having the following elements:

[ <shape>, ...<strides> ]
[ <shape>, ...<strides>, <idx> ]

where

- shape: dimensions sorted in loop order.
- strides: strides for each respective ndarray 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
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ import { ArrayLike } from '@stdlib/types/array';
* - The returned array has the following elements:
*
* ```text
* [ <shape>, ...<strides> ]
* [ <shape>, ...<strides>, <idx> ]
* ```
*
* where
*
* - **shape**: dimensions sorted in loop order.
* - **...strides**: strides for each respective ndarray 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 Down Expand Up @@ -71,6 +72,9 @@ import { ArrayLike } from '@stdlib/types/array';
*
* var ssz = o[ 3 ];
* // returns [ 6, -2, 1 ]
*
* var idx = o[ 4 ];
* // returns [ 2, 1, 0 ]
*/
declare function loopOrder( shape: ArrayLike<number>, strides: ArrayLike<ArrayLike<number>> ): Array<Array<number>>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
*
* var ssz = o[ 3 ];
* // returns [ 6, -2, 1 ]
*
* var idx = o[ 4 ];
* // returns [ 2, 1, 0 ]
*/

// MODULES //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ var sort2ins = require( './sort2ins.js' );
* - The returned array has the following elements:
*
* ```text
* [ <shape>, ...<strides> ]
* [ <shape>, ...<strides>, <idx> ]
* ```
*
* where
*
* - **shape**: dimensions sorted in loop order.
* - **...strides**: strides for each respective ndarray sorted in loop order.
* - **idx**: dimension indices sorted in loop order.
*
* @param {NonNegativeIntegerArray} shape - array dimensions
* @param {ArrayLikeObject<ArrayLikeObject<integer>>} strides - list of stride arrays containing the stride lengths for each input and output ndarray
Expand All @@ -70,6 +71,9 @@ var sort2ins = require( './sort2ins.js' );
*
* var ssz = o[ 3 ];
* // returns [ 6, -2, 1 ]
*
* var idx = o[ 4 ];
* // returns [ 2, 1, 0 ]
*/
function loopOrder( shape, strides ) {
var idx;
Expand Down Expand Up @@ -135,6 +139,9 @@ function loopOrder( shape, strides ) {
for ( i = 0; i < N; i++ ) {
out.push( take( strides[ i ], idx ) );
}
// Append the dimension indices sorted in loop order:
out.push( idx );

return out;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ tape( 'the function returns loop interchange data (row-major)', function test( t
t.strictEqual( isArray( o[ 3 ] ), true, 'returns expected value' );
t.deepEqual( o[ 3 ], [ -2, 4, -8 ], 'returns expected value' );

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

t.strictEqual( o.length, 5, 'returns expected value' );

t.end();
});

Expand Down Expand Up @@ -96,6 +101,11 @@ tape( 'the function returns loop interchange data (column-major)', function test
t.strictEqual( isArray( o[ 3 ] ), true, 'returns expected value' );
t.deepEqual( o[ 3 ], [ -2, 4, -8 ], 'returns expected value' );

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

t.strictEqual( o.length, 5, 'returns expected value' );

t.end();
});

Expand Down Expand Up @@ -129,6 +139,11 @@ tape( 'the function returns loop interchange data (mixed order)', function test(
t.strictEqual( isArray( o[ 3 ] ), true, 'returns expected value' );
t.deepEqual( o[ 3 ], [ -2, 4, -8 ], 'returns expected value' );

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

t.strictEqual( o.length, 5, 'returns expected value' );

t.end();
});

Expand Down Expand Up @@ -162,6 +177,11 @@ tape( 'the function returns loop interchange data (mostly disorganized)', functi
t.strictEqual( isArray( o[ 3 ] ), true, 'returns expected value' );
t.deepEqual( o[ 3 ], [ 4, -2, -8 ], 'returns expected value' );

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

t.strictEqual( o.length, 5, 'returns expected value' );

t.end();
});

Expand Down Expand Up @@ -195,6 +215,11 @@ tape( 'the function returns loop interchange data (all disorganized)', function
t.strictEqual( isArray( o[ 3 ] ), true, 'returns expected value' );
t.deepEqual( o[ 3 ], [ 4, -8, -2 ], 'returns expected value' );

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

t.strictEqual( o.length, 5, 'returns expected value' );

t.end();
});

Expand All @@ -204,5 +229,7 @@ tape( 'if provided empty arrays, the function returns empty arrays', function te
t.deepEqual( o[ 1 ], [], 'returns expected value' );
t.deepEqual( o[ 2 ], [], 'returns expected value' );
t.deepEqual( o[ 3 ], [], 'returns expected value' );
t.deepEqual( o[ 4 ], [], 'returns expected value' );
t.strictEqual( o.length, 5, 'returns expected value' );
t.end();
});
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ The function returns an object having the following properties:
- **sz**: third input array strides sorted in loop order.
- **sw**: fourth input array strides sorted in loop order.
- **su**: output 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
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- sz: third input array strides sorted in loop order.
- sw: fourth input array strides sorted in loop order.
- su: output 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 Expand Up @@ -60,6 +61,9 @@
out.su: Array<integer>
Output 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
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ interface LoopOrderObject {
* Output array strides sorted in loop order.
*/
su: Array<number>;

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

/**
Expand All @@ -70,6 +75,7 @@ interface LoopOrderObject {
* - **sz**: third input ndarray strides sorted in loop order.
* - **sw**: fourth input ndarray strides sorted in loop order.
* - **su**: output 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 Down Expand Up @@ -116,6 +122,9 @@ interface LoopOrderObject {
*
* var ssu = o.su;
* // returns [ 1, -2, 6 ]
*
* var idx = o.idx;
* // returns [ 0, 1, 2 ]
*/
declare function quaternaryLoopOrder( shape: ArrayLike<number>, stridesX: ArrayLike<number>, stridesY: ArrayLike<number>, stridesZ: ArrayLike<number>, stridesW: ArrayLike<number>, stridesU: ArrayLike<number> ): LoopOrderObject;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
*
* var ssu = o.su;
* // returns [ 1, -2, 6 ]
*
* var idx = o.idx;
* // returns [ 0, 1, 2 ]
*/

// MODULES //
Expand Down
Loading
Loading