code: public static void createAutoCorrelation(long[] R, int []samples, int count,
        int start, int increment, int maxOrder) {
      if(increment == 1 && start == 0) {
        for(int i = 0; i <= maxOrder; i++) {
          R[i] = 0;
          long temp = 0;
          for(int j = 0; j < count-i; j++) {
            temp += (long)samples[j]*(long)samples[j+i];
          }
          R[i] += temp;
        }
      }
      else {
        for(int i = 0; i <= maxOrder; i++) {
          R[i] = 0;
          int baseIndex = increment*i;
          long temp = 0;
          int innerLimit = (count-i)*increment;
          for(int j = start; j < innerLimit; j+=increment) {
            temp += (long)samples[j]*(long)samples[j+baseIndex];
          }
          R[i] += temp;
        }
      }
    }
docs: Create auto-correlation coefficients(up to a maxOrder of 32).
  @param R Array to put results in.
  @param samples Samples to calculate the auto-correlation for.
  @param count number of samples to use
  @param start index of samples array to start at
  @param increment number of indices to increment between valid samples(for
  interleaved arrays)
  @param maxOrder maximum order to calculate.