import java.util.*; import java.lang.*; import java.text.*; public class Fit{ private double Data[]; private String Method, Order; private int Degree, N, Ncards, nx, Iorder, Imethod; private double x[][]; private double y[]; private boolean Constant, debug; private Hashtable AllowedMethods, AllowedOrders; private Util util = new Util(); private int Nparms; //Nb. of smoothing parameters private double z[]; //Smoothing parameters private double Y[]; //Fit estimates of y private double b[]; //X[T]y (b of matrix formulation Ax=b) private double rms, Rsquared, MeanSquare, StandardDeviation, correlation; public boolean GAUSS_SINGULAR=false; public boolean WRONG_Nb_DATA=false; public boolean INSUFFICIENT_DATA=false; Fit(double Data[], int N, String Method, String Order, int Degree, boolean Constant, boolean debug){ this.N = N; this.Data = Data; this.Method = Method; this.Order = Order; this.Degree = Degree; this.Constant = Constant; this.debug = debug; SetupOptions(); function_fit(); } public void SetupOptions() { AllowedMethods = new Hashtable(); AllowedMethods.put("polynome", new Integer(0) ); AllowedMethods.put("linear", new Integer(1) ); AllowedOrders = new Hashtable(); AllowedOrders.put("xy", new Integer(0) ); AllowedOrders.put("yx", new Integer(1) ); } public int getMethod() { Integer n = (Integer)AllowedMethods.get(Method); if(n == null){ System.out.println("Illegal method " +Method +" - EXIT -"); System.exit(0); } return(n.intValue()); } public int getOrder() { Integer n = (Integer)AllowedOrders.get(Order); if(n == null){ System.out.println("Illegal order " +Order +" - EXIT -"); System.exit(0); } return(n.intValue()); } public void function_fit() { int i, j, k, m; String StrMethod=null; Imethod = getMethod(); Iorder = getOrder(); switch(Imethod){ case 0: //Polynome nx = 1; break; case 1: //Linear nx = Degree; break; default: break; } k = nx + 1; //Number of values per data card if(N%k != 0){ WRONG_Nb_DATA = true; return; // System.out.print("Illegal number of data - EXIT - "); // System.out.print("from function_fit\n"); // System.exit(0); } Ncards = N / k; //Number of data cards if(Ncards <2){ INSUFFICIENT_DATA = true; return; } // x = new double[Ncards][]; // These are also valid assignments... // for(i=0; i