예제 #1
0
 /** test dimensions */
 public void testDimensions() {
   OpenMapRealMatrix m = createSparseMatrix(testData);
   OpenMapRealMatrix m2 = createSparseMatrix(testData2);
   assertEquals("testData row dimension", 3, m.getRowDimension());
   assertEquals("testData column dimension", 3, m.getColumnDimension());
   assertTrue("testData is square", m.isSquare());
   assertEquals("testData2 row dimension", m2.getRowDimension(), 2);
   assertEquals("testData2 column dimension", m2.getColumnDimension(), 3);
   assertTrue("testData2 is not square", !m2.isSquare());
 }
예제 #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);
     }
   }
 }