package math;

import math.matrix.Matrix;
import exception.IllegalDimensionException;

public class MatrixTest {
   public static void main(String[] args) throws IllegalDimensionException { 
      Matrix A = new Matrix(new double[][] { { 0,  1,  1 },
                                             { 2,  4, -2 },
                                             { 0,  3, 15 } }); 

      Matrix b = new Matrix(new double[][] { {  4 },
                                             {  2 },
                                             { 36 } });
      Matrix x = A.solve(b);
      Matrix residual = A.times(x).minus(b);
      double rnorm = residual.normInf();

      System.out.println("A");
      A.print(9, 6);                // printf("%9.6f");

      System.out.println("b");
      b.print(9, 6);

      System.out.println("x");
      x.print(9, 6);
      System.out.println(x);

      System.out.println("residual");
      residual.print(9, 6);
      
      System.out.println("rnorm");
      System.out.println(rnorm);

   }

}
