import static java.lang.Math.*;
import java.io.*;
import java.util.*;
import javax.swing.*;
import javax.swing.table.*;
import java.awt.*;

    class data
	{
	public double x[];	
	public data(double[] xi)
	{
	int n=xi.length;
	x=new double[n];
	for(int i=0;i<n;i++) {x[i]=xi[i];}
	}	
	public String toString() {return ""+x[0]+" "+x[1];}
	}
	
	public class veri
	{public static double[] dataentry()
    {
    String s=JOptionPane.showInputDialog("ENTER DATA: ");        
    StringTokenizer token=new StringTokenizer(s);
    int n=token.countTokens()-1;
    int m=n+1;
    double a[]=new double[m];
    int j=0;           
    while(token.hasMoreTokens())
    {
    Double ax=new Double(token.nextToken());
    a[j++]=ax.doubleValue();
    }
    return a; 
    }
	//graphic data output method : print (JTable output)
	public static void print(double a)
	{  double b[]=new double[1];
	   b[0]=a;
	   Text.printT(b);
    }
	
    public static double min(double x[])
	{double min=1.99e300;
	 for(int i=0;i<x.length;i++)
	 {if(x[i]<min) min=x[i];}
	 return min;
	}
	
	public static double max(double x[])
	{double max=-1.99e300;
	 for(int i=0;i<x.length;i++)
	 {if(x[i]>max) max=x[i];}
	 return max;
	}
	    public static double min(double mini,double x[])
	{double min=mini;
	 for(int i=0;i<x.length;i++)
	 {if(x[i]<min) min=x[i];}
	 return min;
	}
	
	public static double max(double maxi,double x[])
	{double max=maxi;
	 for(int i=0;i<x.length;i++)
	 {if(x[i]>max) max=x[i];}
	 return max;
	}
	public static double min(double y[][])
	{double min=1.99e300;
	 for(int i=0;i<y.length;i++)
	  for(int j=0;j<y[i].length;j++)
	 {if(y[i][j]<min) min=y[i][j];}
	 return min;
	}
	public static double max(double y[][])
	{double max=-1.99e300;
	 for(int i=0;i<y.length;i++)
	  for(int j=0;j<y[i].length;j++)
	 {if(y[i][j]>max) max=y[i][j];}
	 return max;
	}
	public static double min(double mini,double y[][])
	{double min=mini;
	 for(int i=0;i<y.length;i++)
	  for(int j=0;j<y[i].length;j++)
	 {if(y[i][j]<min) min=y[i][j];}
	 return min;
	}
	public static double max(double maxi,double y[][])
	{double max=maxi;
	 for(int i=0;i<y.length;i++)
	  for(int j=0;j<y[i].length;j++)
	 {if(y[i][j]>max) max=y[i][j];}
	 return max;
	}
    public static void print(double a,String s)
	{  double b[]=new double[1];
	   String s1[]=new String[1];
	   s1[0]=s;
	   b[0]=a;
	   Text.printT(b,s1);
    }
    	
	public static void print(double a[][])
	{Text.printT(a);}
	
	public static void print(double a[][],String baslik[])
	{Text.printT(a,baslik);}
	
    public static void print(double a[][],String baslik[],String bb)
	{Text.printT(a,baslik,bb);}
	
	public static void print(double a[][],String bb)
	{Text.printT(a,bb);}
	
    public static void print(double a[])
	{Text.printT(a);}
	
	public static void print(double a[],String baslik[])
	{Text.printT(a,baslik);}
	
	public static void printT(double a[],String baslik[])
	{Text.print(a,baslik);}
	
    public static void print(double a[],String baslik[],String bb)
	{Text.printT(a,baslik,bb);}
	
	public static void print(double a[],String bb)
	{Text.printT(a,bb);}
	    public static double[][] load(String filename) throws IOException
     {return inputdouble(filename); }             
     public static void save(String filename,double a[][]) throws IOException
     {    FileWriter fout = new FileWriter(filename);
          for(int i=0;i<a.length;i++)
          {for(int j=0;j<a.length;j++)
           {fout.write(a[i][j]+" ");}
            fout.write("\n");
           }
          fout.close();
     }
     public static double[][] inputdouble(String filename) throws IOException
     {
	 //reading double values from one line of data    
	 BufferedReader fin=new BufferedReader(new FileReader(filename));
     double a[][]=inputdouble(fin);
     return a;
     }
     public static void save(String filename,double a[]) throws IOException
     {    FileWriter fout = new FileWriter(filename);
          for(int j=0;j<a.length;j++)
           {fout.write(a[j]+" ");}
            fout.write("\n");
          fout.close();
     } 
    public static String filename()    
    {  String dosyaismi="a.txt";
	   JFileChooser fc=new JFileChooser();
       ExampleFileFilter filter = new ExampleFileFilter();
       filter.addExtension("txt");
       filter.setDescription("read text file");
       fc.setFileFilter(filter);
       if (fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {File file = fc.getSelectedFile();dosyaismi=file.getName(); };
       return dosyaismi;
    }
     public static String[] inputString_fromString(String s)
     { 
	     String s1[]=s.split( "\\n"); 
         return s1;
     }
     public static String[] inputString_fromString(String s,String c1)
     { 
	     String s1[]=s.split(c1); 
         return s1;
     }
     public static double[] inputdouble_fromString(String s)
     {       
     StringTokenizer token=new StringTokenizer(s);
     int n=token.countTokens()-1;
     int m=n+1;
     double a[]=new double[m];
     int j=0;           
     while(token.hasMoreTokens())
     {
     Double ax=new Double(token.nextToken());
     a[j++]=ax.doubleValue();
     }
     return a;
     }
     public static int[] inputInt_fromString(String s)
     {       
     StringTokenizer token=new StringTokenizer(s);
     int n=token.countTokens()-1;
     int m=n+1;
     int a[]=new int[m];
     int j=0;           
     while(token.hasMoreTokens())
     {
    Integer ax=new Integer(token.nextToken());
     a[j++]=ax.intValue();
     }
     return a;
     }
             
    public static double[][] inputdouble(BufferedReader fin) throws IOException
    {
	 ArrayList<data> a=new ArrayList<data>();
	 int mmax=0;
	 double b[][];
	 int n=0,m=0;
	 String s1="";	 
	 try{
       while(fin!=null)
       { s1=fin.readLine();
       if(s1==null)break;
         StringTokenizer token=new StringTokenizer(s1);
         m=token.countTokens();
         if(m>mmax) mmax=m;
         double aa[]=new double[m];
         int j=0;           
         while(token.hasMoreTokens())
         { Double ax=new Double(token.nextToken());
           aa[j++]=ax.doubleValue();
         }
         data vx=new data(aa);
         a.add(vx);
       n++;
	   }
       } catch(EOFException e_eof)
          {
          //close ffile
          try{fin.close();
      } 
      catch(NullPointerException e) {}   
      catch(IOException e)
             {
             System.err.println("Error Closing File\n"+e.toString());
             System.exit(1);
             }
          } //End of EOFException
     b=new double[n][mmax];
     int k=0;
     Iterator<data> i=a.iterator();
     while(i.hasNext()) {data vx=i.next();b[k++]=vx.x;}
     double a1[][]=new double[b[0].length][b.length];
     for(int ii=0;ii<b[0].length;ii++)
     {for(int jj=0;jj<b.length;jj++)
       {a1[ii][jj]=b[jj][ii];}
     }
     return a1;
     }
        public static double[] setX(double xmin,double dx,double xmax)
   {
    int n=(int)((xmax-xmin)/dx+0.00000000000001);
    double x[]=new double[n+1];
    for(int i=0;i<=n;i++)
    {x[i]=xmin+dx*i;}
    x[n]=xmax;
    return x;	   
   }
   
   public static double[] setX(double xmin,double xmax,int n)
   {
    double dx=(xmax-xmin)/n;
    double x[]=new double[n+1];
    for(int i=0;i<=n;i++)
    {x[i]=xmin+dx*i;}
    x[n]=xmax;
    return x;	   
   }
   
   public static double[] setX(double xmin,double xmax)
   { int n=200;
    double dx=(xmax-xmin)/n;
    double x[]=new double[n+1];
    for(int i=0;i<=n;i++)
    {x[i]=xmin+dx*i;}
    x[n]=xmax;
    return x;	   
   }
    
   public static double[] setX(int xmin,int xmax)
   {
    int n=xmax-xmin;
    double x[]=new double[n+1];
    for(int i=0;i<=n;i++)
    {x[i]=xmin+i;}
    return x;	   
   }
        //Function evaluations & creations
   public static String inputfunc()
   {inputA x0=new inputA();
    return x0.vericiktisi();
   }
      public static double[] feval(String function,double x[])
   {return setY(function,x);}
   
   public static double[] feval(f_x ff,double x[])
   {return setY(ff,x);}
   public static double[] feval(if_x ff,double x[])
   {return setY(ff,x);}
   public static double feval(String function,double x)
   {return setY(function,x);}
   
   public static double feval(f_x ff,double x)
   { return ff.func(x);}
   public static double feval(if_x ff,double x)
   { return ff.func(x);}
   public static double[] setY(String function,double x[])
   {
	ce1X x0=new ce1X(function);
	ce2T x1=new ce2T(x);
    double y[]=x1.r;
    return y;	   
   }
   
   public static double[] setY(f_x ff,double x[])
   {
    int n=x.length;;
    double y[]=new double[n];
    for(int i=0;i<n;i++)
    {y[i]=ff.func(x[i]);}
    return y;	   
   }
   public static double[] setY(if_x ff,double x[])
   {
    int n=x.length;;
    double y[]=new double[n];
    for(int i=0;i<n;i++)
    {y[i]=ff.func(x[i]);}
    return y;	   
   }
   public static double setY(String function,double x)
   {
	ce1X x0=new ce1X(function);
	ce2V x1=new ce2V(x);
    double y=x1.r;
    return y;	   
   }
   
   public static double setY(f_x ff,double x)
   { return ff.func(x);}
   
   public static double[] setY(String function,double xmin,double dx,double xmax)
   { double x[]=setX(xmin,dx,xmax);
	ce1X x0=new ce1X(function);
	ce2T x1=new ce2T(x);
    double y[]=x1.r;
    return y;	   
   }
   
   public static double[] func(String function,double x[])
   { return setY(function,x);}
   
   public static double[] func(String function,double xmin,double dx,double xmax)
   { return setY(function,xmin,dx,xmax);}  
      
	} 