Ejemplo n.º 1
0
 public void testBig() throws NoConvergenceException {
   for (int k = 0; k < Abig.length; ++k) {
     Abig[k][k] = 0.1;
     Bbig[k] = k;
   }
   for (int k = 0; k < Abig.length; ++k) {
     for (int l = 0; l < Abig.length; ++l) {
       Abig[k][l] += k * l / 1000.0;
     }
   }
   for (int k = 0; k < Abig.length; ++k) {
     for (int l = 0; l < Abig.length; ++l) {
       Abig[k][l] += (k % 3) * (l % 3) / 10.0;
     }
   }
   long before, after;
   before = System.currentTimeMillis();
   Minres.solve(Abig, Bbig);
   after = System.currentTimeMillis();
   System.out.println("Minres took " + (after - before) / 1000.0 + " seconds");
   before = System.currentTimeMillis();
   SymmLQ.solve(Abig, Bbig);
   after = System.currentTimeMillis();
   System.out.println("Symmlq took " + (after - before) / 1000.0 + " seconds");
   before = System.currentTimeMillis();
   ConjugateGradient.solve(Abig, Bbig);
   after = System.currentTimeMillis();
   System.out.println("ConjugateGradient took " + (after - before) / 1000.0 + " seconds");
   before = System.currentTimeMillis();
   JSciSolver.solve(Abig, Bbig);
   after = System.currentTimeMillis();
   System.out.println("LU Decomposition took " + (after - before) / 1000.0 + " seconds");
 }
Ejemplo n.º 2
0
 public void testSmall() throws NoConvergenceException {
   for (int k = 0; k < Asmall.length; ++k) {
     Asmall[k][k] = 1.0;
     Bsmall[k] = k;
   }
   for (int k = 0; k < Asmall.length; ++k) {
     for (int l = 0; l < Asmall.length; ++l) {
       Asmall[k][l] += k * l / 1000.0;
     }
   }
   UtilMath.print(Minres.solve(Asmall, Bsmall));
   UtilMath.print(SymmLQ.solve(Asmall, Bsmall));
   UtilMath.print(ConjugateGradient.solve(Asmall, Bsmall));
   UtilMath.print(JSciSolver.solve(Asmall, Bsmall));
 }