Skip to content

Commit fbdf99c

Browse files
committed
fix: apply suggestions from code review
1 parent 6bcf4f5 commit fbdf99c

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

  • lib/node_modules/@stdlib/ndarray/base/diagonal/lib

lib/node_modules/@stdlib/ndarray/base/diagonal/lib/main.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,16 @@ function diagonal( x, dims, k, writable ) {
106106
co = ( k > 0 ) ? k : 0;
107107
ro = co - k;
108108

109-
// Compute the length of the diagonal (clamped to be non-negative):
109+
// Compute the length of the diagonal:
110110
rows = sh[ d[0] ] - ro;
111111
cols = sh[ d[1] ] - co;
112112
L = min( rows, cols );
113+
114+
// Adjust the offset so that we point to the first element along the specified diagonal (otherwise, the diagonal is empty and the offset remains at the buffer base):
115+
offset = getOffset( x );
113116
if ( L < 0 ) {
114117
L = 0;
115-
}
116-
// Adjust the offset so that we point to the first element along the specified diagonal:
117-
offset = getOffset( x );
118-
if ( L > 0 ) {
118+
} else {
119119
offset += ( co*sc ) + ( ro*sr );
120120
}
121121

0 commit comments

Comments
 (0)