import java.io.*;

class Matrix3
{
  public static void main(String args[]) throws IOException
  {
  /*
  double a[][];
  a=new double[5][5];
  a[0][0]=1;
  a[0][1]=2;
  a[0][2]=0;
  a[0][3]=0;
  a[0][4]=0;
  a[1][0]=-2;
  a[1][1]=3;
  a[1][2]=0;
  a[1][3]=0;
  a[1][4]=0;
  a[2][0]=3;
  a[2][1]=4;
  a[2][2]=50;
  a[2][3]=0;
  a[2][4]=0;
  a[3][0]=-4;
  a[3][1]=5;
  a[3][2]=-60;
  a[3][3]=7;
  a[3][4]=0;
  a[4][0]=-5;
  a[4][1]=6;
  a[4][2]=-70;
  a[4][3]=8;
  a[4][4]=-9;
  */
  double c[][]=new double[5][5];
  double a[][]={{1,2,0,0,0},{-2,3,0,0,0},{3,4,50,0,0},{-4,5,-60,7,0},
                {-5,6,-70,8,-9}};
  double b[]=new double[5];
  int d[]=new int[1];
  b[0]=1;
  b[1]=0;
  b[2]=0;
  b[3]=0;
  b[4]=0;
  System.out.println("Original Matrix : ");
  System.out.println(Matrix.toString(a));
  System.out.println("Inverse Matrix : (Method inv) ");
  System.out.println(Matrix.toString(Matrix.inv(a)));
  System.out.println("Matrix * Inverse Matrix : (Method multiply) ");
  System.out.println(Matrix.toString(Matrix.multiply(a,Matrix.inv(a))));
  System.out.println("Solution of system of equation : ");
  System.out.println("with second side               : ");
  System.out.println(Matrix.toStringT(b));
  System.out.println(Matrix.toStringT(Matrix.divide(b,a)));
  int indx[]=new int[5];
  d[0]=0;
  c=Matrix.LU(a,indx,d);
  System.out.println("LU decomposed matrix : (Method LU) ");
  System.out.println(Matrix.toString(c));
  System.out.println("Matrix inversion by LU decomposition : (Method LUinv)");
  System.out.println(Matrix.toString(Matrix.LUinv(a)));
  System.out.println("Matrix * Inverse Matrix (LU Decomposition) :");
  System.out.println(Matrix.toString(Matrix.multiply(a,Matrix.LUinv(a))));
  }
}
