Program: 57296
Project: 57296
Buggy source:
/** 
 * Creates   {@code H} of size {@code m x m} as described in [1] (see above).
 * @param d statistic
 * @return H matrix
 * @throws NumberIsTooLargeException if fractional part is greater than 1
 * @throws FractionConversionException if algorithm fails to convert  {@code h} to a{@link org.apache.commons.math.fraction.BigFraction} inexpressing  {@code d} as {@code (k - h) / m} for integer{@code k, m} and {@code 0 <= h < 1}.
 */
private FieldMatrix<BigFraction> createH(double d) throws MathArithmeticException {
  int k=(int)Math.ceil(n * d);
  int m=2 * k - 1;
  double hDouble=k - n * d;
  if (hDouble >= 1) {
    throw new NumberIsTooLargeException(hDouble,1.0,false);
  }
  BigFraction h=null;
  try {
    h=new BigFraction(hDouble,1.0e-20,10000);
  }
 catch (  FractionConversionException e1) {
    try {
      h=new BigFraction(hDouble,1.0e-10,10000);
    }
 catch (    FractionConversionException e2) {
      h=new BigFraction(hDouble,1.0e-5,10000);
    }
  }
  final BigFraction[][] Hdata=new BigFraction[m][m];
  for (int i=0; i < m; ++i) {
    for (int j=0; j < m; ++j) {
      if (i - j + 1 < 0) {
        Hdata[i][j]=BigFraction.ZERO;
      }
 else {
        Hdata[i][j]=BigFraction.ONE;
      }
    }
  }
  final BigFraction[] hPowers=new BigFraction[m];
  hPowers[0]=h;
  for (int i=1; i < m; ++i) {
    hPowers[i]=h.multiply(hPowers[i - 1]);
  }
  for (int i=0; i < m; ++i) {
    Hdata[i][0]=Hdata[i][0].subtract(hPowers[i]);
    Hdata[m - 1][i]=Hdata[m - 1][i].subtract(hPowers[m - i - 1]);
  }
  if (h.compareTo(BigFraction.ONE_HALF) == 1) {
    Hdata[m - 1][0]=Hdata[m - 1][0].add(h.multiply(2).subtract(1).pow(m));
  }
  for (int i=0; i < m; ++i) {
    for (int j=0; j < i + 1; ++j) {
      if (i - j + 1 > 0) {
        for (int g=2; g <= i - j + 1; ++g) {
          Hdata[i][j]=Hdata[i][j].divide(g);
        }
      }
    }
  }
  return new Array2DRowFieldMatrix<BigFraction>(BigFractionField.getInstance(),Hdata);
}

Fixed version (ground truth):
/** 
 * Creates   {@code H} of size {@code m x m} as described in [1] (see above).
 * @param d statistic
 * @return H matrix
 * @throws NumberIsTooLargeException if fractional part is greater than 1
 * @throws FractionConversionException if algorithm fails to convert  {@code h} to a{@link org.apache.commons.math.fraction.BigFraction} inexpressing  {@code d} as {@code (k - h) / m} for integer{@code k, m} and {@code 0 <= h < 1}.
 */
private FieldMatrix<BigFraction> createH(double d) throws NumberIsTooLargeException, FractionConversionException {
  int k=(int)Math.ceil(n * d);
  int m=2 * k - 1;
  double hDouble=k - n * d;
  if (hDouble >= 1) {
    throw new NumberIsTooLargeException(hDouble,1.0,false);
  }
  BigFraction h=null;
  try {
    h=new BigFraction(hDouble,1.0e-20,10000);
  }
 catch (  FractionConversionException e1) {
    try {
      h=new BigFraction(hDouble,1.0e-10,10000);
    }
 catch (    FractionConversionException e2) {
      h=new BigFraction(hDouble,1.0e-5,10000);
    }
  }
  final BigFraction[][] Hdata=new BigFraction[m][m];
  for (int i=0; i < m; ++i) {
    for (int j=0; j < m; ++j) {
      if (i - j + 1 < 0) {
        Hdata[i][j]=BigFraction.ZERO;
      }
 else {
        Hdata[i][j]=BigFraction.ONE;
      }
    }
  }
  final BigFraction[] hPowers=new BigFraction[m];
  hPowers[0]=h;
  for (int i=1; i < m; ++i) {
    hPowers[i]=h.multiply(hPowers[i - 1]);
  }
  for (int i=0; i < m; ++i) {
    Hdata[i][0]=Hdata[i][0].subtract(hPowers[i]);
    Hdata[m - 1][i]=Hdata[m - 1][i].subtract(hPowers[m - i - 1]);
  }
  if (h.compareTo(BigFraction.ONE_HALF) == 1) {
    Hdata[m - 1][0]=Hdata[m - 1][0].add(h.multiply(2).subtract(1).pow(m));
  }
  for (int i=0; i < m; ++i) {
    for (int j=0; j < i + 1; ++j) {
      if (i - j + 1 > 0) {
        for (int g=2; g <= i - j + 1; ++g) {
          Hdata[i][j]=Hdata[i][j].divide(g);
        }
      }
    }
  }
  return new Array2DRowFieldMatrix<BigFraction>(BigFractionField.getInstance(),Hdata);
}