Skip to content

Commit 6653ced

Browse files
committed
[SYSTEMDS-3833] Fix seq() length primitive (pos/neg increment)
1 parent 775d06a commit 6653ced

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main/java/org/apache/sysds/runtime/util/UtilFunctions.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,10 @@ public static long getSeqLength(double from, double to, double incr, boolean che
448448
return 0; // invalid loop configuration
449449
}
450450
long tmp = (long) Math.floor(to/incr - from/incr);
451-
return 1L + tmp + ((from+tmp*incr < to) ? 1 : 0);
451+
if( incr > 0 )
452+
return 1L + tmp + ((from+(tmp+1)*incr <= to) ? 1 : 0);
453+
else
454+
return 1L + tmp + ((from+(tmp+1)*incr >= to) ? 1 : 0);
452455
}
453456

454457
/**

0 commit comments

Comments
 (0)