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 69fd8d4912 [MINOR] Fix robustness matrix construction from empty list
69fd8d4912 is described below
commit 69fd8d4912abea5e7861ed63575c5793ac112e67
Author: Matthias Boehm <[email protected]>
AuthorDate: Thu Apr 7 20:51:58 2022 +0200
[MINOR] Fix robustness matrix construction from empty list
Rbind-ing a list of matrices constructs an concatenated matrix.
However, in special cases where the list is empty, this created index
out of bounds issues. We now define the semantics, of creating proper
0-by-0 matrices in these cases.
---
.../runtime/instructions/cp/MatrixBuiltinNaryCPInstruction.java | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git
a/src/main/java/org/apache/sysds/runtime/instructions/cp/MatrixBuiltinNaryCPInstruction.java
b/src/main/java/org/apache/sysds/runtime/instructions/cp/MatrixBuiltinNaryCPInstruction.java
index 07ab96d190..2560a86560 100644
---
a/src/main/java/org/apache/sysds/runtime/instructions/cp/MatrixBuiltinNaryCPInstruction.java
+++
b/src/main/java/org/apache/sysds/runtime/instructions/cp/MatrixBuiltinNaryCPInstruction.java
@@ -46,8 +46,10 @@ public class MatrixBuiltinNaryCPInstruction extends
BuiltinNaryCPInstruction imp
MatrixBlock outBlock = null;
if( "cbind".equals(getOpcode()) || "rbind".equals(getOpcode())
) {
boolean cbind = "cbind".equals(getOpcode());
- outBlock = matrices.get(0).append(matrices.subList(1,
matrices.size())
- .toArray(new MatrixBlock[0]), new
MatrixBlock(), cbind);
+ //robustness for empty lists: create 0-by-0 matrix block
+ outBlock = matrices.size() == 0 ? new MatrixBlock(0, 0,
0) :
+ matrices.get(0).append(matrices.subList(1,
matrices.size())
+ .toArray(new MatrixBlock[0]), new
MatrixBlock(), cbind);
}
else if( ArrayUtils.contains(new String[]{"nmin", "nmax",
"n+"}, getOpcode()) ) {