示例#1
0
 /** test add failure */
 public void testAddFail() {
   OpenMapRealMatrix m = createSparseMatrix(testData);
   OpenMapRealMatrix m2 = createSparseMatrix(testData2);
   try {
     m.add(m2);
     fail("IllegalArgumentException expected");
   } catch (IllegalArgumentException ex) {
     // ignored
   }
 }
示例#2
0
 /** test add */
 public void testAdd() {
   OpenMapRealMatrix m = createSparseMatrix(testData);
   OpenMapRealMatrix mInv = createSparseMatrix(testDataInv);
   OpenMapRealMatrix mDataPlusInv = createSparseMatrix(testDataPlusInv);
   RealMatrix mPlusMInv = m.add(mInv);
   for (int row = 0; row < m.getRowDimension(); row++) {
     for (int col = 0; col < m.getColumnDimension(); col++) {
       assertEquals(
           "sum entry entry",
           mDataPlusInv.getEntry(row, col),
           mPlusMInv.getEntry(row, col),
           entryTolerance);
     }
   }
 }