class QuasiRegular {

  public static void cubicSpline(float[] inpt, int iIdx, double[] y2d, double x, float[] outpt, int oIdx) {
    // float *inpt; /* input row */
    // int iIdx; /* input data index*/
    // float *y2d; /* second derivatives of input row */
    // float x; /* output point */
    // float outpt; /* where to put the interpolated data */
    // int oIdx; /* index in output, the interpolated data */

    int hi;
    int low;
    double a;
    double b;

    if (java.lang.Math.floor(x) == x) { /* existing data point */
      // *outpt = inpt[(int)x];
      outpt[oIdx] = inpt[iIdx + (int) x];
      return;
    }

    /* set the input bracket */
    hi = (int) (java.lang.Math.ceil(x));
    low = (int) (java.lang.Math.floor(x));

    a = hi - x;
    b = x - low;

    hi = hi > (y2d.length - 1) ? 0 : hi;

    /* evaluate the polynomial */

    // *outpt = a * inpt[low] + b * inpt[hi] + ((a * a * a - a) * y2d[low] +
    // (b * b * b - b) * y2d[hi]) / 6.0;
    outpt[oIdx] = (float) (a * inpt[iIdx + low] + b * inpt[iIdx + hi]
        + ((a * a * a - a) * y2d[low] + (b * b * b - b) * y2d[hi]) / 6.0);

  }

}