You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@systemml.apache.org by mb...@apache.org on 2015/11/25 18:51:25 UTC

[2/4] incubator-systemml git commit: Fix remove empty columns w/ selection vector (awareness of sel flags)

Fix remove empty columns w/ selection vector (awareness of sel flags) 

Project: http://git-wip-us.apache.org/repos/asf/incubator-systemml/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-systemml/commit/3631f23e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-systemml/tree/3631f23e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-systemml/diff/3631f23e

Branch: refs/heads/master
Commit: 3631f23e6ce1711df3a2eb0732438cdcc999f2bc
Parents: 1663303
Author: Matthias Boehm <mb...@us.ibm.com>
Authored: Tue Nov 24 20:27:40 2015 -0800
Committer: Matthias Boehm <mb...@us.ibm.com>
Committed: Tue Nov 24 20:27:40 2015 -0800

----------------------------------------------------------------------
 .../dml/runtime/matrix/data/LibMatrixReorg.java | 27 ++++++++++++--------
 1 file changed, 16 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/3631f23e/src/main/java/com/ibm/bi/dml/runtime/matrix/data/LibMatrixReorg.java
----------------------------------------------------------------------
diff --git a/src/main/java/com/ibm/bi/dml/runtime/matrix/data/LibMatrixReorg.java b/src/main/java/com/ibm/bi/dml/runtime/matrix/data/LibMatrixReorg.java
index 6d8d924..31fe405 100644
--- a/src/main/java/com/ibm/bi/dml/runtime/matrix/data/LibMatrixReorg.java
+++ b/src/main/java/com/ibm/bi/dml/runtime/matrix/data/LibMatrixReorg.java
@@ -1669,8 +1669,8 @@ public class LibMatrixReorg
 		boolean[] flags = null; 
 		int rlen2 = 0; 
 		
-		if(select == null) {
-		
+		if(select == null) 
+		{
 			flags = new boolean[ m ]; //false
 			//Step 1: scan block and determine non-empty rows
 			
@@ -1699,12 +1699,12 @@ public class LibMatrixReorg
 						}
 				}
 			}
-		} else {			
+		} 
+		else {			
 			flags = DataConverter.convertToBooleanVector(select);
 			rlen2 = (int)select.getNonZeros();
 		}
 
-		
 		//Step 2: reset result and copy rows
 		//dense stays dense if correct input representation (but robust for any input), 
 		//sparse might be dense/sparse
@@ -1770,7 +1770,8 @@ public class LibMatrixReorg
 		//(we optimized for cache-friendly behavior and hence don't do early abort)
 		boolean[] flags = null; 
 		
-		if (select == null) {
+		if (select == null) 
+		{
 			flags = new boolean[ n ]; //false
 			if( in.sparse ) //SPARSE 
 			{
@@ -1793,21 +1794,24 @@ public class LibMatrixReorg
 						if( a[aix] != 0 )
 							flags[j] = true; 	
 			}
-		} else {			
+		} 
+		else {			
 			flags = DataConverter.convertToBooleanVector(select);
 		}
 
 		
 		//Step 2: determine number of columns
 		int clen2 = 0;
-		for( int j=0; j<n; j++ )
+		for( int j=0; j<n; j++ ) {
 			clen2 += flags[j] ? 1 : 0;
+		}
 		
 		//Step 3: create mapping of flags to target indexes
 		int[] cix = new int[n];
-		for( int j=0, pos=0; j<n; j++ )
+		for( int j=0, pos=0; j<n; j++ ) {
 			if( flags[j] )
 				cix[j] = pos++;	
+		}
 		
 		//Step 3: reset result and copy cols
 		//dense stays dense if correct input representation (but robust for any input), 
@@ -1827,7 +1831,8 @@ public class LibMatrixReorg
 					int[] aix = a[i].getIndexContainer();
 					double[] avals = a[i].getValueContainer();
 					for( int j=0; j<alen; j++ )
-						ret.appendValue(i, cix[aix[j]], avals[j]);
+						if( flags[aix[j]] )
+							ret.appendValue(i, cix[aix[j]], avals[j]);
 				}
 		}
 		else if( !in.sparse && !ret.sparse )  //DENSE <- DENSE
@@ -1838,7 +1843,7 @@ public class LibMatrixReorg
 			
 			for(int i=0, aix=0, lcix=0; i<m; i++, lcix+=clen2)
 				for(int j=0; j<n; j++, aix++)
-					if( a[aix] != 0 )
+					if( flags[j] )
 						 c[ lcix+cix[j] ] = a[aix];	
 		}
 		else //SPARSE <- DENSE
@@ -1848,7 +1853,7 @@ public class LibMatrixReorg
 			
 			for(int i=0, aix=0; i<m; i++)
 				for(int j=0; j<n; j++, aix++)
-					if( a[aix] != 0 )
+					if( flags[j] && a[aix]!=0 )
 						 ret.appendValue(i, cix[j], a[aix]);	
 		}