Skip to content

Commit 1ec0528

Browse files
committed
fix: bounds and indexing for column wise packing updated
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 51981c7 commit 1ec0528

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

  • lib/node_modules/@stdlib/array/base/banded/to-compact/lib

lib/node_modules/@stdlib/array/base/banded/to-compact/lib/main.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,10 @@ var zeros2d = require( '@stdlib/array/base/zeros2d' );
5454
* ];
5555
*
5656
* var out = toCompact( M, 1, 1, true );
57-
* // returns [ [ 0, 11, 3 ], [ 2, 12, 5 ], [ 4, 13, 0 ] ]
57+
* // returns [ [ 0, 11, 2 ], [ 3, 12, 4 ], [ 5, 13, 0 ] ]
5858
*/
5959
function toCompact( arr, ku, kl, colexicographic ) {
6060
var out;
61-
var to;
6261
var M;
6362
var N;
6463
var i;
@@ -70,12 +69,11 @@ function toCompact( arr, ku, kl, colexicographic ) {
7069

7170
// Check whether to store diagonals along the columns...
7271
if ( colexicographic ) {
73-
out = zeros2d( [ N, ku+kl+1 ] );
74-
for ( j = 0; j < N; j++ ) {
75-
to = out[ j ];
76-
k = ku - j;
77-
for ( i = max( 0, j-ku ); i < min( M, j+kl+1 ); i++ ) {
78-
to[ k+i ] = arr[ i ][ j ];
72+
out = zeros2d( [ M, ku+kl+1 ] );
73+
for ( j = 0; j < M; j++ ) {
74+
k = kl - j;
75+
for ( i = max( 0, j-kl ); i < min( N, j+ku+1 ); i++ ) {
76+
out[ j ][ i+k ] = arr[ j ][ i ];
7977
}
8078
}
8179
return out;

0 commit comments

Comments
 (0)