@@ -82,9 +82,9 @@ public static MatrixBlockDictionary create(MatrixBlock mb, boolean check) {
8282 throw new DMLCompressionException ("Invalid construction of dictionary with null array" );
8383 else if (mb .getNumRows () == 0 || mb .getNumColumns () == 0 )
8484 throw new DMLCompressionException ("Invalid construction of dictionary with zero rows and/or cols array" );
85+ else if (mb .isEmpty ())
86+ return null ;
8587 else if (check ) {
86- if (mb .isEmpty ())
87- return null ;
8888 mb .examSparsity (true );
8989 if (mb .isInSparseFormat () && mb .getSparseBlock () instanceof SparseBlockMCSR ) {
9090 // make CSR sparse block to make it smaller.
@@ -2140,7 +2140,7 @@ private IDictionary replaceWithReferenceNan(double replace, double[] reference)
21402140 int j = 0 ;
21412141 for (int k = apos ; k < alen ; k ++) {
21422142 final double v = avals [k ];
2143- retV [off ++] = Util .eq (Double .NaN , v ) ? replace -reference [j ] : v ;
2143+ retV [off ++] = Util .eq (Double .NaN , v ) ? replace - reference [j ] : v ;
21442144 }
21452145 }
21462146 }
@@ -2149,7 +2149,7 @@ private IDictionary replaceWithReferenceNan(double replace, double[] reference)
21492149 for (int i = 0 ; i < nRow ; i ++) {
21502150 for (int j = 0 ; j < nCol ; j ++) {
21512151 final double v = values [off ];
2152- retV [off ++] = Util .eq (Double .NaN , v ) ? replace -reference [j ] : v ;
2152+ retV [off ++] = Util .eq (Double .NaN , v ) ? replace - reference [j ] : v ;
21532153 }
21542154 }
21552155 }
@@ -2267,10 +2267,9 @@ public void productWithReference(double[] ret, int[] counts, double[] reference,
22672267 final int nCol = _data .getNumColumns ();
22682268 final int nRow = _data .getNumRows ();
22692269
2270-
22712270 final double [] values ;
22722271 // force dense ... if this ever is a bottleneck i will be surprised
2273- if (_data .isInSparseFormat ()){
2272+ if (_data .isInSparseFormat ()) {
22742273 MatrixBlock tmp = new MatrixBlock ();
22752274 tmp .copy (_data );
22762275 tmp .sparseToDense ();
@@ -2511,7 +2510,9 @@ public void TSMMToUpperTriangleSparseScaling(SparseBlock left, IColIndex rowsLef
25112510
25122511 @ Override
25132512 public boolean equals (IDictionary o ) {
2514- if (o instanceof MatrixBlockDictionary )
2513+ if (o == null )
2514+ return false ;
2515+ else if (o instanceof MatrixBlockDictionary )
25152516 return _data .equals (((MatrixBlockDictionary ) o )._data );
25162517 else if (o instanceof Dictionary ) {
25172518 double [] dVals = ((Dictionary ) o )._values ;
@@ -2529,10 +2530,10 @@ else if(_data.isInSparseFormat())
25292530 final double [] dv = _data .getDenseBlockValues ();
25302531 return Arrays .equals (dv , dVals );
25312532 }
2532- else if (o != null )
2533- return o .equals (this );
25342533
2535- return false ;
2534+ // fallback
2535+ return o .equals (this );
2536+
25362537 }
25372538
25382539 @ Override
0 commit comments