Skip to content

Commit 6bcf4f5

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

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

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

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,10 @@ function diagonal( x, dims, k, writable ) {
114114
L = 0;
115115
}
116116
// Adjust the offset so that we point to the first element along the specified diagonal:
117-
offset = getOffset( x ) + ( co*sc ) + ( ro*sr );
117+
offset = getOffset( x );
118+
if ( L > 0 ) {
119+
offset += ( co*sc ) + ( ro*sr );
120+
}
118121

119122
// Drop the specified dimensions and append the diagonal dimension:
120123
shape = [];

0 commit comments

Comments
 (0)