Program: 57103
Project: 57103
Buggy source:
/** 
 * <p> Computes the   {@code n}-th roots of unity. The roots are stored in  {@code omega[]}, such that   {@code omega[k] = w ^ k}, where  {@code k = 0, ..., n - 1},   {@code w = exp(2 * pi * i / n)} and{@code i = sqrt(-1)}. </p> <p> Note that   {@code n} can be positive of negative</p> <ul> <li> {@code abs(n)} is always the number of roots of unity.</li><li>If  {@code n > 0}, then the roots are stored in counter-clockwise order.</li> <li>If   {@code n < 0}, then the roots are stored in clockwise order.</p> </ul>
 * @param n the (signed) number of roots of unity to be computed
 * @throws ZeroException if {@code n = 0}
 */
public synchronized void computeRoots(int n) throws ZeroException {
  if (n == 0) {
    throw new ZeroException(LocalizedFormats.CANNOT_COMPUTE_0TH_ROOT_OF_UNITY);
  }
  isCounterClockWise=n > 0;
  final int absN=FastMath.abs(n);
  if (absN == omegaCount) {
    return;
  }
  final double t=2.0 * FastMath.PI / absN;
  final double cosT=FastMath.cos(t);
  final double sinT=FastMath.sin(t);
  omegaReal=new double[absN];
  omegaImaginaryCounterClockwise=new double[absN];
  omegaImaginaryClockwise=new double[absN];
  omegaReal[0]=1.0;
  omegaImaginaryCounterClockwise[0]=0.0;
  omegaImaginaryClockwise[0]=0.0;
  for (int i=1; i < absN; i++) {
    omegaReal[i]=omegaReal[i - 1] * cosT - omegaImaginaryCounterClockwise[i - 1] * sinT;
    omegaImaginaryCounterClockwise[i]=omegaReal[i - 1] * sinT + omegaImaginaryCounterClockwise[i - 1] * cosT;
    omegaImaginaryClockwise[i]=-omegaImaginaryCounterClockwise[i];
  }
  omegaCount=absN;
}

Fixed version (ground truth):
/** 
 * <p> Computes the   {@code n}-th roots of unity. The roots are stored in  {@code omega[]}, such that   {@code omega[k] = w ^ k}, where  {@code k = 0, ..., n - 1},   {@code w = exp(2 * pi * i / n)} and{@code i = sqrt(-1)}. </p> <p> Note that   {@code n} can be positive of negative</p> <ul> <li> {@code abs(n)} is always the number of roots of unity.</li><li>If  {@code n > 0}, then the roots are stored in counter-clockwise order.</li> <li>If   {@code n < 0}, then the roots are stored in clockwise order. </ul>
 * @param n the (signed) number of roots of unity to be computed
 * @throws ZeroException if {@code n = 0}
 */
public synchronized void computeRoots(int n) throws ZeroException {
  if (n == 0) {
    throw new ZeroException(LocalizedFormats.CANNOT_COMPUTE_0TH_ROOT_OF_UNITY);
  }
  isCounterClockWise=n > 0;
  final int absN=FastMath.abs(n);
  if (absN == omegaCount) {
    return;
  }
  final double t=2.0 * FastMath.PI / absN;
  final double cosT=FastMath.cos(t);
  final double sinT=FastMath.sin(t);
  omegaReal=new double[absN];
  omegaImaginaryCounterClockwise=new double[absN];
  omegaImaginaryClockwise=new double[absN];
  omegaReal[0]=1.0;
  omegaImaginaryCounterClockwise[0]=0.0;
  omegaImaginaryClockwise[0]=0.0;
  for (int i=1; i < absN; i++) {
    omegaReal[i]=omegaReal[i - 1] * cosT - omegaImaginaryCounterClockwise[i - 1] * sinT;
    omegaImaginaryCounterClockwise[i]=omegaReal[i - 1] * sinT + omegaImaginaryCounterClockwise[i - 1] * cosT;
    omegaImaginaryClockwise[i]=-omegaImaginaryCounterClockwise[i];
  }
  omegaCount=absN;
}