Skip to content
Closed
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
20 changes: 10 additions & 10 deletions lib/node_modules/@stdlib/array/base/banded/to-compact/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var zeros2d = require( '@stdlib/array/base/zeros2d' );
* ];
*
* var out = toCompact( M, 1, 1, false );
* // returns [ [ 0, 2, 4 ], [ 11, 12, 13 ], [ 3, 5, 0 ] ]
* // returns [ [ 0, 11, 2 ], [ 3, 12, 4 ], [ 5, 13, 0 ] ]
*
* @example
* var M = [
Expand All @@ -54,7 +54,7 @@ var zeros2d = require( '@stdlib/array/base/zeros2d' );
* ];
*
* var out = toCompact( M, 1, 1, true );
* // returns [ [ 0, 11, 3 ], [ 2, 12, 5 ], [ 4, 13, 0 ] ]
* // returns [ [ 0, 2, 4 ], [ 11, 12, 13 ], [ 3, 5, 0 ] ]
*/
function toCompact( arr, ku, kl, colexicographic ) {
var out;
Expand All @@ -70,22 +70,22 @@ function toCompact( arr, ku, kl, colexicographic ) {

// Check whether to store diagonals along the columns...
if ( colexicographic ) {
out = zeros2d( [ N, ku+kl+1 ] );
out = zeros2d( [ ku+kl+1, N ] );
for ( j = 0; j < N; j++ ) {
to = out[ j ];
k = ku - j;
for ( i = max( 0, j-ku ); i < min( M, j+kl+1 ); i++ ) {
to[ k+i ] = arr[ i ][ j ];
to = out[ k+i ];
to[ j ] = arr[ i ][ j ];
}
}
return out;
}
// Store diagonals along the rows...
out = zeros2d( [ ku+kl+1, N ] );
for ( j = 0; j < N; j++ ) {
k = ku - j;
for ( i = max( 0, j-ku ); i < min( M, j+kl+1 ); i++ ) {
out[ k+i ][ j ] = arr[ i ][ j ];
out = zeros2d( [ M, ku+kl+1 ] );
for ( j = 0; j < M; j++ ) {
k = kl - j;
for ( i = max( 0, j-kl ); i < min( N, j+ku+1 ); i++ ) {
out[ j ][ i+k ] = arr[ j ][ i ];
}
}
return out;
Expand Down
Loading