Program: 76482
Project: 76482
Buggy source:
/** 
 * Return a new matrix that is constructed by inverting the input matrix. If the input matrix is singular, null is returned. This method is from [1]
 * @param matrix A matrix of doubles
 * @return A new matrix of doubles, or null if no inverse exists
 */
public static final double[][] inverse(double[][] A){
  _checkSquare("String_Node_Str",A);
  int n=_rows(A);
  double[][] Ai=allocCopy(A);
  int[] pivotFlag=new int[n];
  int[] swapCol=new int[n];
  int[] swapRow=new int[n];
  int irow=0, icol=0;
  for (int i=0; i < n; i++) {
    double big=0.0;
    for (int row=0; row < n; row++) {
      if (pivotFlag[row] == 0) {
        for (int col=0; col < n; col++) {
          if (pivotFlag[col] == 0) {
            double absElement=Math.abs(Ai[row][col]);
            if (absElement >= big) {
              big=absElement;
              irow=row;
              icol=col;
            }
          }
        }
      }
    }
    pivotFlag[icol]++;
    if (irow != icol) {
      for (int col=0; col < n; col++) {
        double temp=Ai[irow][icol];
        Ai[irow][col]=Ai[icol][col];
        Ai[icol][col]=temp;
      }
    }
    swapRow[i]=irow;
    swapCol[i]=icol;
    if (Ai[icol][icol] == 0.0) {
      return null;
    }
    double pivotInverse=1.0 / A[icol][icol];
    Ai[icol][icol]=1.0;
    for (int col=0; col < n; col++) {
      Ai[icol][col]*=pivotInverse;
    }
    for (int row=0; row < n; row++) {
      if (row != icol) {
        double temp=Ai[row][icol];
        Ai[row][icol]=0.0;
        for (int col=0; col < n; col++) {
          Ai[row][col]-=Ai[icol][col] * temp;
        }
      }
    }
  }
  for (int swap=n - 1; swap >= 0; swap--) {
    if (swapRow[swap] != swapCol[swap]) {
      for (int row=0; row < n; row++) {
        double temp=Ai[row][swapRow[swap]];
        Ai[row][swapRow[swap]]=Ai[row][swapCol[swap]];
        Ai[row][swapCol[swap]]=temp;
      }
    }
  }
  return Ai;
}

Fixed version (ground truth):
/** 
 * Return a new matrix that is constructed by inverting the input matrix. If the input matrix is singular, null is returned. This method is from [1]
 * @param matrix A matrix of doubles
 * @return A new matrix of doubles, or null if no inverse exists
 */
public static final double[][] inverse(double[][] A){
  _checkSquare("String_Node_Str",A);
  int n=_rows(A);
  double[][] Ai=allocCopy(A);
  System.out.println(toString(Ai));
  int[] pivotFlag=new int[n];
  int[] swapCol=new int[n];
  int[] swapRow=new int[n];
  int irow=0, icol=0;
  for (int i=0; i < n; i++) {
    double big=0.0;
    for (int row=0; row < n; row++) {
      if (pivotFlag[row] == 0) {
        for (int col=0; col < n; col++) {
          if (pivotFlag[col] == 0) {
            double absElement=Math.abs(Ai[row][col]);
            if (absElement >= big) {
              big=absElement;
              irow=row;
              icol=col;
            }
          }
        }
      }
    }
    pivotFlag[icol]++;
    if (irow != icol) {
      for (int col=0; col < n; col++) {
        double temp=Ai[irow][col];
        Ai[irow][col]=Ai[icol][col];
        Ai[icol][col]=temp;
      }
    }
    swapRow[i]=irow;
    swapCol[i]=icol;
    if (Ai[icol][icol] == 0.0) {
      return null;
    }
    double pivotInverse=1.0 / Ai[icol][icol];
    Ai[icol][icol]=1.0;
    for (int col=0; col < n; col++) {
      Ai[icol][col]*=pivotInverse;
    }
    for (int row=0; row < n; row++) {
      if (row != icol) {
        double temp=Ai[row][icol];
        Ai[row][icol]=0.0;
        for (int col=0; col < n; col++) {
          Ai[row][col]-=Ai[icol][col] * temp;
        }
      }
    }
  }
  for (int swap=n - 1; swap >= 0; swap--) {
    if (swapRow[swap] != swapCol[swap]) {
      for (int row=0; row < n; row++) {
        double temp=Ai[row][swapRow[swap]];
        Ai[row][swapRow[swap]]=Ai[row][swapCol[swap]];
        Ai[row][swapCol[swap]]=temp;
      }
    }
  }
  return Ai;
}