// lsfit.java tailorable code, add more functions as needed // this version up to 7 independent variables, 7D import java.io.*; import java.text.*; // needs simeq.java public class lsfit { int Apwr[]; // powers of each variable in a term int Bpwr[]; int Cpwr[]; int Dpwr[]; int Epwr[]; int Fpwr[]; int Gpwr[]; boolean debug = true; // user can turn off double A[][]; double C[]; double Y[]; double Av[]; // powers of variables double Bv[]; double Cv[]; double Dv[]; double Ev[]; double Fv[]; double Gv[]; int mm; // dimension, number of variables int n; // highest polygon power int nnn; // number of terms in polygon int ndata; // number of data points to fit DecimalFormat f4 = new DecimalFormat("0.000"); public lsfit(int mm, int n, int ndata) { this.n = n; this.mm = mm; this.ndata = ndata; if(mm==2) gen_2d_powers(); // n, mm sets nnn, Apwr, Bpwr ... if(mm==3) gen_3d_powers(); if(mm==4) gen_4d_powers(); if(mm==5) gen_5d_powers(); if(mm==6) gen_6d_powers(); if(mm==7) gen_7d_powers(); A = new double[nnn][nnn]; C = new double[nnn]; // computed polynomial coefficients Y = new double[nnn]; Av = new double[n+1]; // powers of variables Bv = new double[n+1]; Cv = new double[n+1]; Dv = new double[n+1]; Ev = new double[n+1]; Fv = new double[n+1]; Gv = new double[n+1]; for(int i=0; i