Example #1
0
  private void test(DMatrix a) {
    int m = a.getM();
    int n = a.getN();

    DMatrixLud lud = new DMatrixLud(a);
    int[] piv = lud.getPivot();
    DMatrix l = lud.getL();
    DMatrix u = lud.getU();
    DMatrix lu = l.times(u);
    assertEqualFuzzy(a.get(piv, null), lu);

    if (m == n) {
      int nrhs = 2;
      DMatrix b = DMatrix.random(m, nrhs);
      DMatrix x = lud.solve(b);
      DMatrix ax = a.times(x);
      assertEqualFuzzy(ax, b);
    }
  }
Example #2
0
 public void testRandom() {
   test(DMatrix.random(100, 100));
   test(DMatrix.random(101, 100));
 }