This is an automated email from the ASF dual-hosted git repository. baunsgaard pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/systemds.git
commit 37520e8d27ea4d1489a90f192abca7c35baeab59 Author: baunsgaard <[email protected]> AuthorDate: Wed Oct 12 20:41:18 2022 +0200 [MINOR] Update the internal printing of DenseBlock This is a minor update to refine the printing of internal DenseBlocks to make the print more pleasing and easy to debug with. Two things are done: 1. Double values that are equal to the long casted version is printed without tailing zeros. 2. If a DenseBlock is a column vector print the numbers in a single line. To not just print many new lines. The change does not effect any performance since these methods only are called when debugging or calling toString() on a MatrixBlock. --- .../org/apache/sysds/runtime/data/DenseBlock.java | 36 ++++++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/apache/sysds/runtime/data/DenseBlock.java b/src/main/java/org/apache/sysds/runtime/data/DenseBlock.java index c2ca0c8f24..5a08fb4896 100644 --- a/src/main/java/org/apache/sysds/runtime/data/DenseBlock.java +++ b/src/main/java/org/apache/sysds/runtime/data/DenseBlock.java @@ -646,21 +646,37 @@ public abstract class DenseBlock implements Serializable @Override public String toString() { StringBuilder sb = new StringBuilder(); - for(int i=0; i<_rlen; i++) { - double[] data = values(i); - int ix = pos(i); - for(int j=0; j<_odims[0]; j++) { - double v = data[ix+j]; - if(v == (long) v) - sb.append((long)v); - else - sb.append(data[ix+j]); - sb.append(" "); + if(_odims[0] == 1) { + sb.append("Printing column vector transposed:\n"); + for(int b = 0; b < numBlocks(); b++) { + for(double v : valuesAt(b)) { + sb.append(getNiceFormat(v)); + sb.append(" "); + } } sb.append("\n"); } + else{ + for(int i=0; i<_rlen; i++) { + double[] data = values(i); + int ix = pos(i); + for(int j=0; j<_odims[0]; j++) { + double v = data[ix+j]; + sb.append(getNiceFormat(v)); + sb.append(" "); + } + sb.append("\n"); + } + } return sb.toString(); } + + private String getNiceFormat(double v) { + if(v == (long) v) + return Long.toString((long) v); + else + return Double.toString(v); + } protected double[] getReuseRow(boolean reset) { if( _reuse != null && reset )
