/* timing module for LU factorization */ import java.util.Random; import jnt.linear_algebra.LU; import jnt.linear_algebra.JBLAS; import jnt.util.Stopwatch; import jnt.io.NumericIO; public class tLU { static private final int DEBUG=0; public static void main(String args[]) { double A[][]; int N; if (args.length < 1) { System.out.println("Usage -f matrix-filename reps"); System.out.println(" N reps (use random-matrices)"); return; } if (args[0].compareTo("-f") == 0) // initialize usinge file { A = NumericIO.readMatrixDouble(args[1]); N = A.length; } else // initialize using random matrices { N = Integer.valueOf(args[0]).intValue(); A = new double[N][N]; Random R = new Random(); for (int i=0; i 0) { System.out.println("LU: "); NumericIO.write(tA); System.out.println("solution x:"); NumericIO.write(x); System.out.println("A*x: "); NumericIO.write( JBLAS.mult(A,x)); } System.out.println("LU error |Ax-b|: " + JBLAS.norm2( JBLAS.minus(JBLAS.mult(A, x), b ))); Q.reset(); Q.start(); for (int i=0; i 0.0) System.out.println(" Mflops: " + (reps*1.0e-6)*ops / Q.read()); else System.out.println("Time too small."); // now time triangular solve part // LU LUA = new LU(A); Q.reset(); Q.start(); for (int i=0; i 0.0) System.out.println(" Mflops: " + (reps*1.0e-6)* N*N / Q.read()); else System.out.println("Time too small."); } }