import java.util.Locale;
public class matrix
 {
	 
 public double A[][];
 //constructor methods
 public matrix(double Ai[][])
 { A=new double[Ai.length][Ai[0].length];
   input_matrix(Ai); 
 }
 
 public matrix(matrix M)
 { A=new double[M.A.length][M.A[0].length];
   input_matrix(M.A); 
 }
 
 public matrix(int n,int m)
 { A=new double[n][m];
   for(int i=0;i<n;i++)
	 { for(int j=0;j<m;j++)
	   {A[i][j]=0.0;}
     }  
 }
 
 public void input_matrix(double Ai[][])
 {   for(int i=0;i<A.length;i++)
	 { for(int j=0;j<A[0].length;j++)
	   {A[i][j]=Ai[i][j];}
     }
 }
 
 public static matrix add(matrix M1,matrix M2)
 {
 //
 int n=M1.A.length;
 int m=M1.A[0].length;
 matrix M3=new matrix(n,m);
  for(int i=0;i<n;i++)
	 { for(int j=0;j<m;j++)
	   {M3.A[i][j]=M1.A[i][j]+M2.A[i][j];}
     }  
 return M3;	   
 }
 
 public static matrix add(double[][] A1,double[][] A2)
 {
 //
 int n=A1.length;
 int m=A1[0].length;
 matrix M=new matrix(n,m);
  for(int i=0;i<n;i++)
	 { for(int j=0;j<m;j++)
	   {M.A[i][j]=A1[i][j]+A2[i][j];}
     }  
 return M;	   
 }
 
 public void add(matrix M1)
 {
 //	 
 int n=A.length;
 int m=A[0].length;
  for(int i=0;i<n;i++)
	 { for(int j=0;j<m;j++)
	   {A[i][j]+=M1.A[i][j];}
     }  	   
 }
 
 public void add(double [][] B)
 {
 //	 
 int n=A.length;
 int m=A[0].length;
  for(int i=0;i<n;i++)
	 { for(int j=0;j<m;j++)
	   {A[i][j]+=B[i][j];}
     }  	   
 }
 
 public static String toString(matrix M)
 { int n=M.A.length;
   int m=M.A[0].length;
   String s="";
  for(int i=0;i<n;i++)
	 { for(int j=0;j<m;j++)
	   {s+=M.A[i][j]+" ";}
	 s+="\n";
	 }
 return s;
 }
 
 public String toString()
 {  Locale tr=new Locale("TR");
	int n=A.length;
   int m=A[0].length;
   String s1="";
   for(int i=0;i<n;i++)
   {  for(int j=0;j<m;j++)
    { s1+=String.format(tr," %10.5f ",A[i][j]);}
   s1+="\n";
   }
 return s1;
 } //toString metodunun sonu	 	 
 
 }//matrix sınıfının sonu
