@@ -377,6 +377,64 @@ public void getValues() {
377377 }
378378 }
379379
380+ @ Test
381+ public void getNumValues () {
382+ assertEquals (a .getNumberOfValues (nCol ), b .getNumberOfValues (nCol ));
383+ }
384+
385+ @ Test (expected = Exception .class )
386+ public void getNumValuesInvalida () {
387+ a .getNumberOfValues (nCol + 1 );
388+ throw new RuntimeException ("pass" );
389+ }
390+
391+ @ Test (expected = Exception .class )
392+ public void getNumValuesInvalidb () {
393+ b .getNumberOfValues (nCol + 1 );
394+ throw new RuntimeException ("pass" );
395+ }
396+
397+ @ Test
398+ public void getNumColumns () {
399+ assertEquals (a .getNumberOfColumns (nRow ), b .getNumberOfColumns (nRow ));
400+ }
401+
402+ @ Test (expected = Exception .class )
403+ public void getNumColumnsInvalida () {
404+ a .getNumberOfColumns (nRow + 1 );
405+ throw new RuntimeException ("pass" );
406+ }
407+
408+ @ Test (expected = Exception .class )
409+ public void getNumColumnsInvalidb () {
410+ b .getNumberOfColumns (nRow + 1 );
411+ throw new RuntimeException ("pass" );
412+ }
413+
414+ @ Test (expected = Exception .class )
415+ public void outOfRange1 () {
416+ assertEquals (0 , a .getValue (nRow , nCol - 1 , nCol ), 0.0 );
417+ throw new RuntimeException ();
418+ }
419+
420+ @ Test (expected = Exception .class )
421+ public void outOfRange2 () {
422+ assertEquals (0 , b .getValue (nRow , nCol - 1 , nCol ), 0.0 );
423+ throw new RuntimeException ();
424+ }
425+
426+ @ Test (expected = Exception .class )
427+ public void outOfRange3 () {
428+ assertEquals (0 , a .getValue (nRow * nCol + 1 ), 0.0 );
429+ throw new RuntimeException ();
430+ }
431+
432+ @ Test (expected = Exception .class )
433+ public void outOfRange4 () {
434+ assertEquals (0 , b .getValue (nRow * nCol + 1 ), 0.0 );
435+ throw new RuntimeException ();
436+ }
437+
380438 @ Test
381439 public void getDictType () {
382440 assertNotEquals (a .getDictType (), b .getDictType ());
@@ -726,6 +784,13 @@ public void sliceOutColumnRange() {
726784 compare (ad , bd , nRow , e - s );
727785 }
728786
787+ @ Test
788+ public void sliceOutEverything () {
789+ IDictionary ad = a .sliceOutColumnRange (0 , nCol , nCol );
790+ IDictionary bd = b .sliceOutColumnRange (0 , nCol , nCol );
791+ compare (ad , bd , nRow , nCol );
792+ }
793+
729794 @ Test
730795 public void contains1 () {
731796 containsValue (1 );
@@ -1184,6 +1249,61 @@ public void rightMMPreAggSparse() {
11841249
11851250 }
11861251
1252+ @ Test
1253+ public void rightMMPreAggUltraSparse () {
1254+ final int nColsOut = 30 ;
1255+ MatrixBlock sparse = TestUtils .generateTestMatrixBlock (1000 , nColsOut , -10 , 10 , 0.001 , 100 );
1256+ sparse = TestUtils .ceil (sparse );
1257+ sparse .denseToSparse (true );
1258+ SparseBlock sb = sparse .getSparseBlock ();
1259+ if (sb == null )
1260+ throw new NotImplementedException ();
1261+
1262+ IColIndex agCols = new RangeIndex (nColsOut );
1263+ IColIndex thisCols = new RangeIndex (0 , nCol );
1264+
1265+ int nVals = a .getNumberOfValues (nCol );
1266+ try {
1267+
1268+ IDictionary aa = a .rightMMPreAggSparse (nVals , sb , thisCols , agCols , nColsOut );
1269+ IDictionary bb = b .rightMMPreAggSparse (nVals , sb , thisCols , agCols , nColsOut );
1270+ compare (aa , bb , nColsOut );
1271+ }
1272+ catch (Exception e ) {
1273+ e .printStackTrace ();
1274+ fail (e .getMessage ());
1275+ }
1276+
1277+ }
1278+
1279+
1280+ @ Test
1281+ public void rightMMPreAggUltraSparseTwoOut () {
1282+ final int nColsOut = 2 ;
1283+ MatrixBlock sparse = TestUtils .generateTestMatrixBlock (1000 , nColsOut , -10 , 10 , 0.001 , 100 );
1284+ sparse = TestUtils .ceil (sparse );
1285+ sparse .denseToSparse (true );
1286+ SparseBlock sb = sparse .getSparseBlock ();
1287+ if (sb == null )
1288+ throw new NotImplementedException ();
1289+
1290+ IColIndex agCols = new RangeIndex (nColsOut );
1291+ IColIndex thisCols = new RangeIndex (0 , nCol );
1292+
1293+ int nVals = a .getNumberOfValues (nCol );
1294+ try {
1295+
1296+ IDictionary aa = a .rightMMPreAggSparse (nVals , sb , thisCols , agCols , nColsOut );
1297+ IDictionary bb = b .rightMMPreAggSparse (nVals , sb , thisCols , agCols , nColsOut );
1298+ compare (aa , bb , nColsOut );
1299+ }
1300+ catch (Exception e ) {
1301+ e .printStackTrace ();
1302+ fail (e .getMessage ());
1303+ }
1304+
1305+ }
1306+
11871307 @ Test
11881308 public void rightMMPreAggSparse2 () {
11891309 final int nColsOut = 1000 ;
@@ -1238,6 +1358,35 @@ public void rightMMPreAggSparseDifferentColumns() {
12381358
12391359 }
12401360
1361+
1362+ @ Test
1363+ public void rightMMPreAggSparseDifferentColumnsUltraSparse () {
1364+ final int nColsOut = 3 ;
1365+ MatrixBlock sparse = TestUtils .generateTestMatrixBlock (1000 , 50 , -10 , 10 , 0.001 , 100 );
1366+ sparse = TestUtils .ceil (sparse );
1367+ sparse .denseToSparse (true );
1368+ SparseBlock sb = sparse .getSparseBlock ();
1369+ if (sb == null )
1370+ throw new NotImplementedException ();
1371+
1372+ IColIndex agCols = new ArrayIndex (new int [] {4 , 10 , 38 });
1373+ IColIndex thisCols = new RangeIndex (0 , nCol );
1374+
1375+ int nVals = a .getNumberOfValues (nCol );
1376+ try {
1377+
1378+ IDictionary aa = a .rightMMPreAggSparse (nVals , sb , thisCols , agCols , 50 );
1379+ IDictionary bb = b .rightMMPreAggSparse (nVals , sb , thisCols , agCols , 50 );
1380+ compare (aa , bb , nColsOut );
1381+ }
1382+ catch (Exception e ) {
1383+ e .printStackTrace ();
1384+ fail (e .getMessage ());
1385+ }
1386+
1387+ }
1388+
1389+
12411390 @ Test
12421391 public void MMDictScalingDense () {
12431392 double [] left = TestUtils .ceil (TestUtils .generateTestVector (a .getNumberOfValues (nCol ) * 3 , -10 , 10 , 1.0 , 3214 ));
0 commit comments