public static void polcof(final double[] xa, final double[] ya, final double[] cof){
    int k,j,i,n=xa.length;
    double xmin;
    double[] x = new double[n];
    double[] y = new double[n];
    for (j=0;j<n;j++) {
      x[j]=xa[j];
      y[j]=ya[j];
    }
    for (j=0;j<n;j++) {
      double[] x_t = new double[n-j];
      double[] y_t = new double[n-j];
      for (k=0;k<n-j;k++) {
        x_t[k]=x[k];
        y_t[k]=y[k];
      }
      Poly_interp interp = new Poly_interp(x,y,n-j);
      cof[j] = interp.rawinterp(0,0.);
      xmin=1.0e99;
      k = -1;
      for (i=0;i<n-j;i++) {
        if (abs(x[i]) < xmin) {
          xmin=abs(x[i]);
          k=i;
        }
        if (x[i] != 0.0)
          y[i]=(y[i]-cof[j])/x[i];
      }
      for (i=k+1;i<n-j;i++) {
        y[i-1]=y[i];
        x[i-1]=x[i];
      }
    }
  }