This is an automated email from the ASF dual-hosted git repository.
mboehm7 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/systemds.git
The following commit(s) were added to refs/heads/main by this push:
new 6653ced2e4 [SYSTEMDS-3833] Fix seq() length primitive (pos/neg
increment)
6653ced2e4 is described below
commit 6653ced2e44640f31b9cfd4d8b04d0d387972f4c
Author: Matthias Boehm <[email protected]>
AuthorDate: Sun Feb 9 13:02:02 2025 +0100
[SYSTEMDS-3833] Fix seq() length primitive (pos/neg increment)
---
src/main/java/org/apache/sysds/runtime/util/UtilFunctions.java | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/main/java/org/apache/sysds/runtime/util/UtilFunctions.java
b/src/main/java/org/apache/sysds/runtime/util/UtilFunctions.java
index 0530c0b6bc..f233b69a11 100644
--- a/src/main/java/org/apache/sysds/runtime/util/UtilFunctions.java
+++ b/src/main/java/org/apache/sysds/runtime/util/UtilFunctions.java
@@ -448,7 +448,10 @@ public class UtilFunctions {
return 0; // invalid loop configuration
}
long tmp = (long) Math.floor(to/incr - from/incr);
- return 1L + tmp + ((from+tmp*incr < to) ? 1 : 0);
+ if( incr > 0 )
+ return 1L + tmp + ((from+(tmp+1)*incr <= to) ? 1 : 0);
+ else
+ return 1L + tmp + ((from+(tmp+1)*incr >= to) ? 1 : 0);
}
/**