public BaryRat_interp(final double[] xv, final double[] yv, final int dd) {
    super(xv, yv, xv.length);
    w = new double[n];
    d = dd;
    
    if (n<=d) throw new IllegalArgumentException("d too large for number of points in BaryRat_interp");
    for (int k=0;k<n;k++) {
      int imin=max(k-d,0);
      int imax = (k >= n-d) ? n-d-1 : k;
      double temp = (imin & 1)!=0 ? -1.0 : 1.0;
      //double temp = imin & 1 ? -1.0 : 1.0;
      double sum=0.0;
      for (int i=imin;i<=imax;i++) {
        int jmax=min(i+d,n-1);
        double term=1.0;
        for (int j=i;j<=jmax;j++) {
          if (j==k) continue;
          term *= (xx[k]-xx[j]);
        }
        term=temp/term;
        temp=-temp;
        sum += term;
      }
      w[k]=sum;
    }
  }