nus-yam/ex-repair huggingface dataset:
Program: 30048
Project: 30048
Buggy source:
/** 
 * @return 
 */
private WB_FaceListMesh triangulateST(){
  tris=new FastTable<int[]>();
  int[] face;
  int[][] triangles;
  int id=0;
  for (  final int[] face2 : faces) {
    face=face2;
    if (face.length == 3) {
      addTriangle(face);
    }
 else {
      triangles=WB_Triangulate.getPolygonTriangulation2D(face,vertices,true,geometryfactory.createEmbeddedPlane(getPlane(id))).getTriangles();
      for (      final int[] triangle : triangles) {
        addTriangle(triangle);
      }
    }
    id++;
  }
  faces=new int[tris.size()][3];
  int i=0;
  for (  final int[] tri : tris) {
    faces[i++]=tri;
  }
  return this;
}

Fixed version (ground truth):
/** 
 * @return
 */
private WB_FaceListMesh triangulateST(){
  tris=new FastTable<int[]>();
  int[] face;
  int[][] triangles;
  int id=0;
  for (  final int[] face2 : faces) {
    face=face2;
    if (face.length == 3) {
      addTriangle(face);
    }
 else {
      triangles=new WB_Triangulate().getPolygonTriangulation2D(face,vertices,true,geometryfactory.createEmbeddedPlane(getPlane(id))).getTriangles();
      for (      final int[] triangle : triangles) {
        addTriangle(triangle);
      }
    }
    id++;
  }
  faces=new int[tris.size()][3];
  int i=0;
  for (  final int[] tri : tris) {
    faces[i++]=tri;
  }
  return this;
}
Program: 30049
Project: 30049
Buggy source:
/** 
 * @param i 
 * @return 
 */
public double k1(final int i){
  if (!curvaturesUpdated) {
    updateCurvatures();
  }
  return curv1[i];
}

Fixed version (ground truth):
/** 
 * @param i
 * @return
 */
public double k1(final int i){
  if (!curvaturesUpdated) {
    updateCurvatures();
  }
  return curv1[i];
}
Program: 30050
Project: 30050
Buggy source:
/** 
 * @param i 
 * @return 
 */
public double k2(final int i){
  if (!curvaturesUpdated) {
    updateCurvatures();
  }
  return curv2[i];
}

Fixed version (ground truth):
/** 
 * @param i
 * @return
 */
public double k2(final int i){
  if (!curvaturesUpdated) {
    updateCurvatures();
  }
  return curv2[i];
}
Program: 30051
Project: 30051
Buggy source:
/** 
 * @param i 
 * @return 
 */
public int[] getFace(final int i){
  return faces[i];
}

Fixed version (ground truth):
/** 
 * @param i
 * @return
 */
public int[] getFace(final int i){
  return faces[i];
}
Program: 30052
Project: 30052
Buggy source:
/** 
 * @param points 
 * @param faces 
 */
protected WB_FaceListMesh(final double[] points,final int[][] faces){
  vertices=geometryfactory.createPointSequence(points);
  this.faces=new int[faces.length][];
  int i=0;
  for (  final int[] face : faces) {
    this.faces[i]=new int[face.length];
    for (int j=0; j < face.length; j++) {
      this.faces[i][j]=face[j];
    }
    i++;
  }
}

Fixed version (ground truth):
/** 
 * @param points
 * @param faces
 */
protected WB_FaceListMesh(final double[] points,final int[][] faces){
  vertices=geometryfactory.createPointSequence(points);
  this.faces=new int[faces.length][];
  int i=0;
  for (  final int[] face : faces) {
    this.faces[i]=new int[face.length];
    for (int j=0; j < face.length; j++) {
      this.faces[i][j]=face[j];
    }
    i++;
  }
}
Program: 30053
Project: 30053
Buggy source:
/** 
 * @param s 
 * @param e 
 */
FaceNormalRunner(final int s,final int e){
  start=s;
  end=e;
}

Fixed version (ground truth):
/** 
 * @param s
 * @param e
 */
FaceNormalRunner(final int s,final int e){
  start=s;
  end=e;
}
Program: 30054
Project: 30054
Buggy source:
/** 
 * @return 
 */
public double k2min(){
  if (!curvaturesUpdated) {
    updateCurvatures();
  }
  return k2min;
}

Fixed version (ground truth):
/** 
 * @return
 */
public double k2min(){
  if (!curvaturesUpdated) {
    updateCurvatures();
  }
  return k2min;
}
Program: 30055
Project: 30055
Buggy source:
/** 
 * @return 
 */
public List<WB_Polygon> getPolygons(){
  final List<WB_Polygon> polygons=new FastTable<WB_Polygon>();
  for (int i=0; i < faces.length; i++) {
    polygons.add(getPolygon(i));
  }
  return polygons;
}

Fixed version (ground truth):
/** 
 * @return
 */
public List<WB_Polygon> getPolygons(){
  final List<WB_Polygon> polygons=new FastTable<WB_Polygon>();
  for (int i=0; i < faces.length; i++) {
    polygons.add(getPolygon(i));
  }
  return polygons;
}
Program: 30056
Project: 30056
Buggy source:
/** 
 * @param i 
 * @return 
 */
public double DCurvInvariant(final int i){
  if (!DCurvaturesUpdated) {
    updateDCurvatures();
  }
  return (dcurv[i][0] * dcurv[i][0]) + (dcurv[i][1] * dcurv[i][1]) + (dcurv[i][2] * dcurv[i][2])+ (dcurv[i][3] * dcurv[i][3]);
}

Fixed version (ground truth):
/** 
 * @param i
 * @return
 */
public double DCurvInvariant(final int i){
  if (!DCurvaturesUpdated) {
    updateDCurvatures();
  }
  return (dcurv[i][0] * dcurv[i][0]) + (dcurv[i][1] * dcurv[i][1]) + (dcurv[i][2] * dcurv[i][2])+ (dcurv[i][3] * dcurv[i][3]);
}
Program: 30057
Project: 30057
Buggy source:
/** 
 * @param i 
 * @return 
 */
public double[] DCurv(final int i){
  if (!DCurvaturesUpdated) {
    updateDCurvatures();
  }
  return dcurv[i];
}

Fixed version (ground truth):
/** 
 * @param i
 * @return
 */
public double[] DCurv(final int i){
  if (!DCurvaturesUpdated) {
    updateDCurvatures();
  }
  return dcurv[i];
}
Program: 30058
Project: 30058
Buggy source:
/** 
 * @param i 
 * @return 
 */
public double K(final int i){
  if (!curvaturesUpdated) {
    updateCurvatures();
  }
  return curv2[i] * curv1[i];
}

Fixed version (ground truth):
/** 
 * @param i
 * @return
 */
public double K(final int i){
  if (!curvaturesUpdated) {
    updateCurvatures();
  }
  return curv2[i] * curv1[i];
}
Program: 30059
Project: 30059
Buggy source:
/** 
 * @return 
 */
public WB_FaceListMesh get(){
  return new WB_FaceListMesh(this);
}

Fixed version (ground truth):
/** 
 * @return
 */
public WB_FaceListMesh get(){
  return new WB_FaceListMesh(this);
}
Program: 30060
Project: 30060
Buggy source:
/** 
 * @return 
 */
public List<WB_Plane> getPlanes(){
  return getPlanes(0);
}

Fixed version (ground truth):
/** 
 * @return
 */
public List<WB_Plane> getPlanes(){
  return getPlanes(0);
}
Program: 30061
Project: 30061
Buggy source:
/** 
 * @param id 
 * @return 
 */
public WB_Plane getPlane(final int id){
  return getPlane(id,0);
}

Fixed version (ground truth):
/** 
 * @param id
 * @return
 */
public WB_Plane getPlane(final int id){
  return getPlane(id,0);
}
Program: 30062
Project: 30062
Buggy source:
/** 
 * @param i 
 * @return 
 */
public WB_Vector k1dir(final int i){
  if (!curvaturesUpdated) {
    updateCurvatures();
  }
  return pdir1[i];
}

Fixed version (ground truth):
/** 
 * @param i
 * @return
 */
public WB_Vector k1dir(final int i){
  if (!curvaturesUpdated) {
    updateCurvatures();
  }
  return pdir1[i];
}
Program: 30063
Project: 30063
Buggy source:
/** 
 * @param AABB 
 * @return 
 */
public WB_FaceListMesh isoFitInAABB(final WB_AABB AABB){
  final WB_AABB self=getAABB();
  final double scx=self.getCenterX();
  final double acx=AABB.getCenterX();
  final double scy=self.getCenterY();
  final double acy=AABB.getCenterY();
  final double scz=self.getCenterZ();
  final double acz=AABB.getCenterZ();
  double f=Math.min(AABB.getWidth() / self.getWidth(),AABB.getHeight() / self.getHeight());
  f=Math.min(f,AABB.getDepth() / self.getDepth());
  final List<WB_SequencePoint> rescaled=new FastTable<WB_SequencePoint>();
  for (int i=0; i < vertices.size(); i++) {
    final WB_SequencePoint p=vertices.getPoint(i);
    p.addSelf(-scx,-scy,-scz);
    p.mulSelf(f);
    p.addSelf(acx,acy,acz);
    rescaled.add(p);
  }
  return geometryfactory.createMesh(rescaled,faces);
}

Fixed version (ground truth):
/** 
 * @param AABB
 * @return
 */
public WB_FaceListMesh isoFitInAABB(final WB_AABB AABB){
  final WB_AABB self=getAABB();
  final double scx=self.getCenterX();
  final double acx=AABB.getCenterX();
  final double scy=self.getCenterY();
  final double acy=AABB.getCenterY();
  final double scz=self.getCenterZ();
  final double acz=AABB.getCenterZ();
  double f=Math.min(AABB.getWidth() / self.getWidth(),AABB.getHeight() / self.getHeight());
  f=Math.min(f,AABB.getDepth() / self.getDepth());
  final List<WB_SequencePoint> rescaled=new FastTable<WB_SequencePoint>();
  for (int i=0; i < vertices.size(); i++) {
    final WB_SequencePoint p=vertices.getPoint(i);
    p.addSelf(-scx,-scy,-scz);
    p.mulSelf(f);
    p.addSelf(acx,acy,acz);
    rescaled.add(p);
  }
  return geometryfactory.createMesh(rescaled,faces);
}
Program: 30064
Project: 30064
Buggy source:
/** 
 * @param tri 
 */
synchronized void addTriangle(final int[] tri){
  tris.add(tri);
}

Fixed version (ground truth):
/** 
 * @param tri
 */
synchronized void addTriangle(final int[] tri){
  tris.add(tri);
}
Program: 30065
Project: 30065
Buggy source:
/** 
 * @param i 
 * @return 
 */
public WB_Vector k2dir(final int i){
  if (!curvaturesUpdated) {
    updateCurvatures();
  }
  return pdir2[i];
}

Fixed version (ground truth):
/** 
 * @param i
 * @return
 */
public WB_Vector k2dir(final int i){
  if (!curvaturesUpdated) {
    updateCurvatures();
  }
  return pdir2[i];
}
Program: 30066
Project: 30066
Buggy source:
/** 
 * @return 
 */
@SuppressWarnings("String_Node_Str") private WB_FaceListMesh triangulateMT(){
  tris=Collections.synchronizedList(new FastTable<int[]>());
  final int threadCount=Runtime.getRuntime().availableProcessors();
  final int dfaces=faces.length / threadCount;
  final ExecutorService executor=Executors.newFixedThreadPool(threadCount);
  int i=0;
  for (i=0; i < (threadCount - 1); i++) {
    final Runnable runner=new TriangulateRunner(dfaces * i,(dfaces * (i + 1)) - 1);
    executor.submit(runner);
  }
  final Runnable runner=new TriangulateRunner(dfaces * i,faces.length - 1);
  executor.submit(runner);
  executor.shutdown();
  try {
    executor.awaitTermination(Long.MAX_VALUE,TimeUnit.NANOSECONDS);
  }
 catch (  final InterruptedException e) {
    e.printStackTrace();
  }
  faces=new int[tris.size()][3];
  i=0;
  for (  final int[] tri : tris) {
    faces[i++]=tri;
  }
  return this;
}

Fixed version (ground truth):
/** 
 * @return
 */
@SuppressWarnings("String_Node_Str") private WB_FaceListMesh triangulateMT(){
  tris=Collections.synchronizedList(new FastTable<int[]>());
  final int threadCount=Runtime.getRuntime().availableProcessors();
  final int dfaces=faces.length / threadCount;
  final ExecutorService executor=Executors.newFixedThreadPool(threadCount);
  int i=0;
  for (i=0; i < (threadCount - 1); i++) {
    final Runnable runner=new TriangulateRunner(dfaces * i,(dfaces * (i + 1)) - 1);
    executor.submit(runner);
  }
  final Runnable runner=new TriangulateRunner(dfaces * i,faces.length - 1);
  executor.submit(runner);
  executor.shutdown();
  try {
    executor.awaitTermination(Long.MAX_VALUE,TimeUnit.NANOSECONDS);
  }
 catch (  final InterruptedException e) {
    e.printStackTrace();
  }
  faces=new int[tris.size()][3];
  i=0;
  for (  final int[] tri : tris) {
    faces[i++]=tri;
  }
  return this;
}
Program: 30067
Project: 30067
Buggy source:
/** 
 * @param optimize
 * @return
 */
public int[][] getTriangles(final boolean optimize){
  if (triangles == null) {
    if (numberOfShellPoints < 3) {
      return new int[][]{{0,0,0}};
    }
 else     if ((numberOfShellPoints == 3) && (numberOfContours == 1)) {
      return new int[][]{{0,1,2}};
    }
 else     if ((numberOfShellPoints == 4) && (numberOfContours == 1)) {
      return WB_Triangulate.triangulateQuad(points.getPoint(0),points.getPoint(1),points.getPoint(2),points.getPoint(3));
    }
 else {
      final WB_Triangulation2D triangulation=WB_Triangulate.getPolygonTriangulation2D(this,optimize);
      triangles=triangulation.getTriangles();
    }
  }
  return triangles;
}

Fixed version (ground truth):
/** 
 * @param optimize
 * @return
 */
public int[][] getTriangles(final boolean optimize){
  if (triangles == null) {
    if (numberOfShellPoints < 3) {
      return new int[][]{{0,0,0}};
    }
 else     if ((numberOfShellPoints == 3) && (numberOfContours == 1)) {
      return new int[][]{{0,1,2}};
    }
 else     if ((numberOfShellPoints == 4) && (numberOfContours == 1)) {
      return WB_Triangulate.triangulateQuad(points.getPoint(0),points.getPoint(1),points.getPoint(2),points.getPoint(3));
    }
 else {
      final WB_Triangulation2D triangulation=new WB_Triangulate().getPolygonTriangulation2D(this,optimize);
      triangles=triangulation.getTriangles();
    }
  }
  return triangles;
}
Program: 30068
Project: 30068
Buggy source:
/** 
 * @return 
 */
public HE_Mesh createWithQuickHull(){
  if (points == null) {
    return new HE_Mesh();
  }
  if (numberOfPoints == 0) {
    numberOfPoints=points.length;
  }
  final WB_QuickHull3D hull=new WB_QuickHull3D(points);
  final int[][] faceIndices=hull.getFaces();
  final int[] originalindices=hull.getVertexPointIndices();
  final HEC_FromFacelist ffl=new HEC_FromFacelist().setVertices(hull.getVertices()).setFaces(faceIndices).setDuplicate(false).setCheckNormals(false);
  final HE_Mesh result=ffl.createBase();
  vertexToPointIndex=new FastMap<Long,Integer>();
  final Iterator<HE_Vertex> vItr=result.vItr();
  int i=0;
  while (vItr.hasNext()) {
    vertexToPointIndex.put(vItr.next().key(),originalindices[i++]);
  }
  result.cleanUnusedElementsByFace();
  return result;
}

Fixed version (ground truth):
/** 
 * @return
 */
public HE_Mesh createWithQuickHull(){
  if (points == null) {
    return new HE_Mesh();
  }
  if (numberOfPoints == 0) {
    numberOfPoints=points.length;
  }
  final WB_QuickHull3D hull=new WB_QuickHull3D(points);
  final int[][] faceIndices=hull.getFaces();
  final int[] originalindices=hull.getVertexPointIndices();
  final HEC_FromFacelist ffl=new HEC_FromFacelist().setVertices(hull.getVertices()).setFaces(faceIndices).setDuplicate(false).setCheckNormals(false);
  final HE_Mesh result=ffl.createBase();
  vertexToPointIndex=new FastMap<Long,Integer>();
  final Iterator<HE_Vertex> vItr=result.vItr();
  int i=0;
  while (vItr.hasNext()) {
    vertexToPointIndex.put(vItr.next().key(),originalindices[i++]);
  }
  result.cleanUnusedElementsByFace();
  return result;
}
Program: 30069
Project: 30069
Buggy source:
/** 
 * Grow the tracers.
 * @param tracers the tracers
 * @param index the index
 */
private void grow(final WB_Point[] tracers,final int index){
  final WB_KDTree<WB_Point,Integer> kdtree=new WB_KDTree<WB_Point,Integer>();
  for (int i=0; i < numberOfPoints; i++) {
    kdtree.add(points[i],i);
  }
  final WB_Point c=new WB_Point(points[index]);
  WB_Point p;
  WB_Vector r;
  double d2self=0;
  for (int i=0; i < numTracers; i++) {
    p=tracers[i];
    r=dir[i];
    d2self=0;
    double stepSize=traceStep;
    int j=index;
    while (stepSize > WB_Epsilon.EPSILON) {
      while ((j == index) && (d2self < (cutoff * cutoff))) {
        p.addSelf(stepSize * r.xd(),stepSize * r.yd(),stepSize * r.zd());
        d2self=WB_GeometryOp.getSqDistance3D(p,c);
        final WB_KDEntry<WB_Point,Integer>[] closest=kdtree.getNearestNeighbors(p,2);
        j=closest[1].value;
      }
      if (j != index) {
        p.subSelf(stepSize * r.xd(),stepSize * r.yd(),stepSize * r.zd());
        d2self=0;
        stepSize/=2;
      }
 else {
        p.set(c.xd() + (cutoff * r.xd()),c.yd() + (cutoff * r.yd()),c.zd() + (cutoff * r.zd()));
        stepSize=-1;
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Grow the tracers.
 * @param tracers the tracers
 * @param index the index
 */
private void grow(final WB_Point[] tracers,final int index){
  final WB_KDTree<WB_Point,Integer> kdtree=new WB_KDTree<WB_Point,Integer>();
  for (int i=0; i < numberOfPoints; i++) {
    kdtree.add(points[i],i);
  }
  final WB_Point c=new WB_Point(points[index]);
  WB_Point p;
  WB_Vector r;
  double d2self=0;
  for (int i=0; i < numTracers; i++) {
    p=tracers[i];
    r=dir[i];
    d2self=0;
    double stepSize=traceStep;
    int j=index;
    while (stepSize > WB_Epsilon.EPSILON) {
      while ((j == index) && (d2self < (cutoff * cutoff))) {
        p.addSelf(stepSize * r.xd(),stepSize * r.yd(),stepSize * r.zd());
        d2self=WB_GeometryOp.getSqDistance3D(p,c);
        final WB_KDEntry<WB_Point,Integer>[] closest=kdtree.getNearestNeighbors(p,1);
        j=closest[0].value;
      }
      if (j != index) {
        p.subSelf(stepSize * r.xd(),stepSize * r.yd(),stepSize * r.zd());
        d2self=0;
        stepSize/=2;
      }
 else {
        p.set(c.xd() + (cutoff * r.xd()),c.yd() + (cutoff * r.yd()),c.zd() + (cutoff * r.zd()));
        stepSize=-1;
      }
    }
  }
}
Program: 30070
Project: 30070
Buggy source:
@Override public HE_Mesh apply(final HE_Selection selection){
  selection.parent.triangulate(selection);
  final List<HE_Halfedge> edges=selection.getInnerEdges();
  HE_Vertex a, b, c, d;
  int devpre, devpost;
  for (  final HE_Halfedge e : edges) {
    if (!e.isBoundary() && (e.getEdgeDihedralAngle() > threshold)) {
      a=e.getVertex();
      b=e.getPair().getVertex();
      c=e.getNextInFace().getEndVertex();
      d=e.getPair().getNextInFace().getEndVertex();
      devpre=Math.abs(((a.isBoundary()) ? 4 : 6) - a.getVertexOrder());
      devpre+=Math.abs(((b.isBoundary()) ? 4 : 6) - b.getVertexOrder());
      devpre+=Math.abs(((c.isBoundary()) ? 4 : 6) - c.getVertexOrder());
      devpre+=Math.abs(((d.isBoundary()) ? 4 : 6) - d.getVertexOrder());
      if (selection.parent.flipEdge(e)) {
        devpost=Math.abs(((a.isBoundary()) ? 4 : 6) - a.getVertexOrder());
        devpost+=Math.abs(((b.isBoundary()) ? 4 : 6) - b.getVertexOrder());
        devpost+=Math.abs(((b.isBoundary()) ? 4 : 6) - c.getVertexOrder());
        devpost+=Math.abs(((b.isBoundary()) ? 4 : 6) - d.getVertexOrder());
        if (devpre <= devpost) {
          selection.parent.flipEdge(e);
        }
      }
    }
  }
  return selection.parent;
}

Fixed version (ground truth):
@Override public HE_Mesh apply(final HE_Selection selection){
  selection.parent.triangulate(selection);
  final List<HE_Halfedge> edges=selection.getInnerEdges();
  HE_Vertex a, b, c, d;
  int devpre, devpost;
  for (int r=0; r < 2; r++) {
    for (    final HE_Halfedge e : edges) {
      if (!e.isBoundary() && (e.getEdgeDihedralAngle() > threshold)) {
        a=e.getVertex();
        b=e.getPair().getVertex();
        c=e.getNextInFace().getEndVertex();
        d=e.getPair().getNextInFace().getEndVertex();
        devpre=Math.abs(((a.isBoundary()) ? 4 : 6) - a.getVertexOrder());
        devpre+=Math.abs(((b.isBoundary()) ? 4 : 6) - b.getVertexOrder());
        devpre+=Math.abs(((c.isBoundary()) ? 4 : 6) - c.getVertexOrder());
        devpre+=Math.abs(((d.isBoundary()) ? 4 : 6) - d.getVertexOrder());
        if (selection.parent.flipEdge(e)) {
          devpost=Math.abs(((a.isBoundary()) ? 4 : 6) - a.getVertexOrder());
          devpost+=Math.abs(((b.isBoundary()) ? 4 : 6) - b.getVertexOrder());
          devpost+=Math.abs(((b.isBoundary()) ? 4 : 6) - c.getVertexOrder());
          devpost+=Math.abs(((b.isBoundary()) ? 4 : 6) - d.getVertexOrder());
          if (devpre <= devpost) {
            selection.parent.flipEdge(e);
          }
        }
      }
    }
  }
  return selection.parent;
}
Program: 30072
Project: 30072
Buggy source:
public WB_Point p1(){
  return p1;
}

Fixed version (ground truth):
@Override public WB_Point p1(){
  return p1;
}
Program: 30073
Project: 30073
Buggy source:
public WB_Point p2(){
  return p2;
}

Fixed version (ground truth):
@Override public WB_Point p2(){
  return p2;
}
Program: 30074
Project: 30074
Buggy source:
public WB_Point p3(){
  return p3;
}

Fixed version (ground truth):
@Override public WB_Point p3(){
  return p3;
}
Program: 30075
Project: 30075
Buggy source:
/** 
 * Get plane of triangle.
 * @return WB_Plane
 */
public WB_Plane getPlane(){
  final WB_Plane P=new WB_Plane(p1,p2,p3);
  if (P.getNormal().getSqLength() < WB_Epsilon.SQEPSILON) {
    return null;
  }
  return P;
}

Fixed version (ground truth):
/** 
 * Get plane of triangle.
 * @return WB_Plane
 */
@Override public WB_Plane getPlane(){
  final WB_Plane P=new WB_Plane(p1,p2,p3);
  if (P.getNormal().getSqLength() < WB_Epsilon.SQEPSILON) {
    return null;
  }
  return P;
}
Program: 30076
Project: 30076
Buggy source:
/** 
 * Get orthocenter.
 * @return orthocenter
 */
public WB_Point getOrthocenter(){
  final double a2=a * a;
  final double b2=b * b;
  final double c2=c * c;
  return getPointFromBarycentric((a2 + b2 - c2) * (a2 - b2 + c2),(a2 + b2 - c2) * (-a2 + b2 + c2),(a2 - b2 + c2) * (-a2 + b2 + c2));
}

Fixed version (ground truth):
/** 
 * Get orthocenter.
 * @return orthocenter
 */
@Override public WB_Point getOrthocenter(){
  final double a2=a * a;
  final double b2=b * b;
  final double c2=c * c;
  return getPointFromBarycentric((a2 + b2 - c2) * (a2 - b2 + c2),(a2 + b2 - c2) * (-a2 + b2 + c2),(a2 - b2 + c2) * (-a2 + b2 + c2));
}
Program: 30077
Project: 30077
Buggy source:
/** 
 * Get centroid.
 * @return centroid
 */
public WB_Point getCentroid(){
  return getPointFromTrilinear(b * c,c * a,a * b);
}

Fixed version (ground truth):
/** 
 * Get centroid.
 * @return centroid
 */
@Override public WB_Point getCentroid(){
  return getPointFromTrilinear(b * c,c * a,a * b);
}
Program: 30078
Project: 30078
Buggy source:
/** 
 * Barycentric.
 * @param p the p
 * @return the w b_ point
 */
public WB_Point getBarycentric(final WB_Coordinate p){
  final WB_Vector m=p3.subToVector(p1).cross(p2.subToVector(p1));
  double nu, nv, ood;
  final double x=WB_Math.fastAbs(m.xd());
  final double y=WB_Math.fastAbs(m.yd());
  final double z=WB_Math.fastAbs(m.zd());
  if (x >= y && x >= z) {
    nu=WB_Triangle.twiceSignedTriArea2D(p.yd(),p.zd(),p2.yd(),p2.zd(),p3.yd(),p3.zd());
    nv=WB_Triangle.twiceSignedTriArea2D(p.yd(),p.zd(),p3.yd(),p3.zd(),p1.yd(),p1.zd());
    ood=1.0 / m.xd();
  }
 else   if (y >= x && y >= z) {
    nu=WB_Triangle.twiceSignedTriArea2D(p.xd(),p.zd(),p2.xd(),p2.zd(),p3.xd(),p3.zd());
    nv=WB_Triangle.twiceSignedTriArea2D(p.xd(),p.zd(),p3.xd(),p3.zd(),p1.xd(),p1.zd());
    ood=-1.0 / m.yd();
  }
 else {
    nu=WB_Triangle.twiceSignedTriArea2D(p.xd(),p.yd(),p2.xd(),p2.yd(),p3.xd(),p3.yd());
    nv=WB_Triangle.twiceSignedTriArea2D(p.xd(),p.yd(),p3.xd(),p3.yd(),p1.xd(),p1.yd());
    ood=-1.0 / m.zd();
  }
  nu*=ood;
  nv*=ood;
  return new WB_Point(nu,nv,1 - nu - nv);
}

Fixed version (ground truth):
/** 
 * Barycentric.
 * @param p the p
 * @return the w b_ point
 */
@Override public WB_Point getBarycentric(final WB_Coordinate p){
  final WB_Vector m=p3.subToVector(p1).cross(p2.subToVector(p1));
  double nu, nv, ood;
  final double x=WB_Math.fastAbs(m.xd());
  final double y=WB_Math.fastAbs(m.yd());
  final double z=WB_Math.fastAbs(m.zd());
  if (x >= y && x >= z) {
    nu=WB_Triangle.twiceSignedTriArea2D(p.yd(),p.zd(),p2.yd(),p2.zd(),p3.yd(),p3.zd());
    nv=WB_Triangle.twiceSignedTriArea2D(p.yd(),p.zd(),p3.yd(),p3.zd(),p1.yd(),p1.zd());
    ood=1.0 / m.xd();
  }
 else   if (y >= x && y >= z) {
    nu=WB_Triangle.twiceSignedTriArea2D(p.xd(),p.zd(),p2.xd(),p2.zd(),p3.xd(),p3.zd());
    nv=WB_Triangle.twiceSignedTriArea2D(p.xd(),p.zd(),p3.xd(),p3.zd(),p1.xd(),p1.zd());
    ood=-1.0 / m.yd();
  }
 else {
    nu=WB_Triangle.twiceSignedTriArea2D(p.xd(),p.yd(),p2.xd(),p2.yd(),p3.xd(),p3.yd());
    nv=WB_Triangle.twiceSignedTriArea2D(p.xd(),p.yd(),p3.xd(),p3.yd(),p1.xd(),p1.yd());
    ood=-1.0 / m.zd();
  }
  nu*=ood;
  nv*=ood;
  return new WB_Point(nu,nv,1 - nu - nv);
}
Program: 30079
Project: 30079
Buggy source:
/** 
 * Get point from barycentric coordinates.
 * @param x the x
 * @param y the y
 * @param z the z
 * @return point
 */
public WB_Point getPointFromBarycentric(final double x,final double y,final double z){
  return getPointFromTrilinear(x / a,y / b,z / c);
}

Fixed version (ground truth):
/** 
 * Get point from barycentric coordinates.
 * @param x the x
 * @param y the y
 * @param z the z
 * @return point
 */
@Override public WB_Point getPointFromBarycentric(final double x,final double y,final double z){
  return getPointFromTrilinear(x / a,y / b,z / c);
}
Program: 30080
Project: 30080
Buggy source:
/** 
 * Get point from trilinear coordinates.
 * @param x the x
 * @param y the y
 * @param z the z
 * @return point
 */
public WB_Point getPointFromTrilinear(final double x,final double y,final double z){
  final double abc=a * x + b * y + c * z;
  final WB_Point ea=p2.sub(p3);
  final WB_Point eb=p1.sub(p3);
  ea._mulSelf(b * y);
  eb._mulSelf(a * x);
  ea._addSelf(eb);
  ea._divSelf(abc);
  ea._addSelf(p3);
  return ea;
}

Fixed version (ground truth):
/** 
 * Get point from trilinear coordinates.
 * @param x the x
 * @param y the y
 * @param z the z
 * @return point
 */
@Override public WB_Point getPointFromTrilinear(final double x,final double y,final double z){
  final double abc=a * x + b * y + c * z;
  final WB_Point ea=p2.sub(p3);
  final WB_Point eb=p1.sub(p3);
  ea._mulSelf(b * y);
  eb._mulSelf(a * x);
  ea._addSelf(eb);
  ea._divSelf(abc);
  ea._addSelf(p3);
  return ea;
}
Program: 30081
Project: 30081
Buggy source:
/** 
 * Get circumcenter.
 * @return circumcenter
 */
public WB_Point getCircumcenter(){
  return getPointFromTrilinear(cosA,cosB,cosC);
}

Fixed version (ground truth):
/** 
 * Get circumcenter.
 * @return circumcenter
 */
@Override public WB_Point getCircumcenter(){
  return getPointFromTrilinear(cosA,cosB,cosC);
}
Program: 30083
Project: 30083
Buggy source:
private void buildPaths(final HE_Selection cutEdges){
  paths=new FastTable<HE_Path>();
  if (cutEdges.getNumberOfEdges() == 0) {
    return;
  }
  final List<HE_Halfedge> edges=new FastTable<HE_Halfedge>();
  for (  final HE_Halfedge he : cutEdges.getEdgesAsList()) {
    final HE_Face f=he.getFace();
    if (WB_Classify.classifyPointToPlane(P,f.getFaceCenter()) == WB_Classification.BACK) {
      edges.add(he.getPair());
    }
 else {
      edges.add(he);
    }
  }
  while (edges.size() > 0) {
    final List<HE_Halfedge> pathedges=new FastTable<HE_Halfedge>();
    HE_Halfedge current=edges.get(0);
    pathedges.add(current);
    boolean loop=false;
    for (int i=0; i < edges.size(); i++) {
      if (edges.get(i).getVertex() == current.getEndVertex()) {
        if (i > 0) {
          current=edges.get(i);
          pathedges.add(current);
          i=0;
        }
 else {
          loop=true;
          break;
        }
      }
    }
    paths.add(new HE_Path(pathedges,loop));
    edges.removeAll(pathedges);
  }
}

Fixed version (ground truth):
private void buildPaths(final HE_Selection cutEdges){
  paths=new FastTable<HE_Path>();
  if (cutEdges.getNumberOfEdges() == 0) {
    return;
  }
  final List<HE_Halfedge> edges=new FastTable<HE_Halfedge>();
  for (  final HE_Halfedge he : cutEdges.getEdgesAsList()) {
    final HE_Face f=he.getFace();
    if (WB_Classify.classifyPointToPlane(P,f.getFaceCenter()) == WB_Classification.BACK) {
      edges.add(he.getPair());
    }
 else {
      edges.add(he);
    }
  }
  while (edges.size() > 0) {
    final List<HE_Halfedge> pathedges=new FastTable<HE_Halfedge>();
    HE_Halfedge current=edges.get(0);
    pathedges.add(current);
    boolean loop=false;
    for (int i=0; i < edges.size(); i++) {
      if (edges.get(i).getVertex() == current.getEndVertex()) {
        if (i > 0) {
          current=edges.get(i);
          pathedges.add(current);
          i=0;
        }
 else {
          loop=true;
          break;
        }
      }
    }
    if (!loop) {
      final List<HE_Halfedge> reversepathedges=new FastTable<HE_Halfedge>();
      current=edges.get(0);
      for (int i=0; i < edges.size(); i++) {
        if (edges.get(i).getEndVertex() == current.getVertex()) {
          if (i > 0) {
            current=edges.get(i);
            reversepathedges.add(current);
            i=0;
          }
        }
      }
      final List<HE_Halfedge> finalpathedges=new FastTable<HE_Halfedge>();
      for (int i=reversepathedges.size() - 1; i > -1; i--) {
        finalpathedges.add(reversepathedges.get(i));
      }
      finalpathedges.addAll(pathedges);
      paths.add(new HE_Path(finalpathedges,loop));
      edges.removeAll(finalpathedges);
    }
 else {
      paths.add(new HE_Path(pathedges,loop));
      edges.removeAll(pathedges);
    }
  }
}
Program: 30084
Project: 30084
Buggy source:
@Override public String toString(){
  String string="String_Node_Str";
  int i=0;
  for (i=0; i < 3 - 1; i++) {
    string+=_min[0] + "String_Node_Str" + _max[0]+ "String_Node_Str";
  }
  string+=_min[i] + "String_Node_Str" + _max[i]+ "String_Node_Str";
  return string;
}

Fixed version (ground truth):
@Override public String toString(){
  String string="String_Node_Str";
  int i=0;
  for (i=0; i < 3 - 1; i++) {
    string+=_min[i] + "String_Node_Str" + _max[i]+ "String_Node_Str";
  }
  string+=_min[i] + "String_Node_Str" + _max[i]+ "String_Node_Str";
  return string;
}
Program: 30085
Project: 30085
Buggy source:
private void updateHeap(final List<HE_Vertex> vertices){
  double min;
  double c;
  HE_Halfedge minhe;
  List<HE_Halfedge> vstar;
  double vvi;
  for (  final HE_Vertex v : vertices) {
    vvi=visualImportance(v);
    v.setInternalLabel(counter);
    vertexCost.remove(v.key());
    vstar=v.getHalfedgeStar();
    minhe=vstar.get(0);
    min=Double.POSITIVE_INFINITY;
    if (v.isBoundary()) {
      for (int i=0; i < vstar.size(); i++) {
        if (vstar.get(i).isBoundary()) {
          c=halfedgeCollapseCost(vstar.get(i));
          if (c < min) {
            min=c;
            minhe=vstar.get(i);
          }
        }
      }
    }
 else {
      for (int i=0; i < vstar.size(); i++) {
        c=halfedgeCollapseCost(vstar.get(i));
        if (c < min) {
          min=c;
          minhe=vstar.get(i);
        }
      }
    }
    if (min != Double.POSITIVE_INFINITY) {
      vertexCost.put(v.key(),min * vvi);
      v.setHalfedge(minhe);
      heap.push(min * vvi,v);
    }
  }
}

Fixed version (ground truth):
private void updateHeap(final List<HE_Vertex> vertices,final HE_MeshStructure selection){
  double min;
  double c;
  HE_Halfedge minhe;
  List<HE_Halfedge> vstar;
  double vvi;
  for (  final HE_Vertex v : vertices) {
    if (selection == null || selection.contains(v)) {
      vvi=visualImportance(v);
      v.setInternalLabel(counter);
      vertexCost.remove(v.key());
      vstar=v.getHalfedgeStar();
      minhe=vstar.get(0);
      min=Double.POSITIVE_INFINITY;
      if (v.isBoundary()) {
        for (int i=0; i < vstar.size(); i++) {
          if (vstar.get(i).isBoundary()) {
            c=halfedgeCollapseCost(vstar.get(i));
            if (c < min) {
              min=c;
              minhe=vstar.get(i);
            }
          }
        }
      }
 else {
        for (int i=0; i < vstar.size(); i++) {
          c=halfedgeCollapseCost(vstar.get(i));
          if (c < min) {
            min=c;
            minhe=vstar.get(i);
          }
        }
      }
      if (min != Double.POSITIVE_INFINITY) {
        vertexCost.put(v.key(),min * vvi);
        v.setHalfedge(minhe);
        heap.push(min * vvi,v);
      }
    }
  }
}
Program: 30086
Project: 30086
Buggy source:
@Override public HE_Mesh apply(final HE_Selection selection){
  return apply(selection.parent);
}

Fixed version (ground truth):
@Override public HE_Mesh apply(final HE_Selection selection){
  if (selection.parent.getNumberOfVertices() <= goal) {
    return selection.parent;
  }
  _mesh=selection.parent;
  _mesh.triangulate();
  _mesh.resetVertexInternalLabels();
  if (_mesh.getNumberOfVertices() <= 4) {
    return _mesh;
  }
  buildHeap(selection);
  HE_Vertex v;
  Entry entry;
  List<HE_Vertex> vertices;
  while (_mesh.getNumberOfVertices() > goal && heap.size() > 0 && _mesh.getNumberOfVertices() > 4) {
    boolean valid=false;
    do {
      entry=heap.pop();
      v=entry.v;
      valid=selection.contains(v) && (entry.version == v.getInternalLabel());
    }
 while (heap.size() > 0 && !valid);
    if (valid) {
      vertices=v.getNeighborVertices();
      if (_mesh.collapseHalfedge(v.getHalfedge())) {
        vertexCost.remove(v.key());
        selection.remove(v);
        counter++;
        updateHeap(vertices,selection);
      }
    }
  }
  return _mesh;
}
Program: 30087
Project: 30087
Buggy source:
/** 
 * Begin save.
 * @param fn the fn
 */
public static void beginSave(final String fn,final String name){
  try {
    objStream=new FileOutputStream(new File(fn,name + "String_Node_Str"));
    mtlStream=new FileOutputStream(new File(fn,name + "String_Node_Str"));
    handleBeginSave();
  }
 catch (  final Exception e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
/** 
 * Begin save.
 * @param fn the fn
 */
public static void beginSave(final String fn,final String name){
  try {
    objStream=createOutputStream(new File(fn,name + "String_Node_Str"));
    mtlStream=createOutputStream(new File(fn,name + "String_Node_Str"));
    handleBeginSave();
  }
 catch (  final Exception e) {
    e.printStackTrace();
  }
}
Program: 30088
Project: 30088
Buggy source:
public WB_CoordinateSystem setY(final double yx,final double yy,final double yz){
  final WB_Vector lY=new WB_Vector(yx,yy,yz);
  lY._normalizeSelf();
  final WB_Vector tmp=lY.cross(_Y);
  if (!WB_Epsilon.isZeroSq(tmp.getSqLength())) {
    rotate(-Math.acos(_Y.dot(lY)),tmp);
  }
 else   if (_Y.dot(lY) < -1 + WB_Epsilon.EPSILON) {
    flipY();
  }
  return this;
}

Fixed version (ground truth):
public WB_CoordinateSystem setY(final double yx,final double yy,final double yz){
  final WB_Vector lY=new WB_Vector(yx,yy,yz);
  lY._normalizeSelf();
  final WB_Vector tmp=lY.cross(_Y);
  if (!WB_Epsilon.isZeroSq(tmp.getSqLength())) {
    rotate(-Math.acos(WB_Math.clamp(_Y.dot(lY),-1,1)),tmp);
  }
 else   if (_Y.dot(lY) < -1 + WB_Epsilon.EPSILON) {
    flipY();
  }
  return this;
}
Program: 30089
Project: 30089
Buggy source:
public WB_CoordinateSystem setX(final double xx,final double xy,final double xz){
  final WB_Vector lX=new WB_Vector(xx,xy,xz);
  lX._normalizeSelf();
  final WB_Vector tmp=lX.cross(_X);
  if (!WB_Epsilon.isZeroSq(tmp.getSqLength())) {
    rotate(-Math.acos(_X.dot(lX)),tmp);
  }
 else   if (_X.dot(lX) < -1 + WB_Epsilon.EPSILON) {
    flipX();
  }
  return this;
}

Fixed version (ground truth):
public WB_CoordinateSystem setX(final double xx,final double xy,final double xz){
  final WB_Vector lX=new WB_Vector(xx,xy,xz);
  lX._normalizeSelf();
  final WB_Vector tmp=lX.cross(_X);
  if (!WB_Epsilon.isZeroSq(tmp.getSqLength())) {
    rotate(-Math.acos(WB_Math.clamp(_X.dot(lX),-1,1)),tmp);
  }
 else   if (_X.dot(lX) < -1 + WB_Epsilon.EPSILON) {
    flipX();
  }
  return this;
}
Program: 30090
Project: 30090
Buggy source:
public WB_CoordinateSystem setZ(final double zx,final double zy,final double zz){
  final WB_Vector lZ=new WB_Vector(zx,zy,zz);
  lZ._normalizeSelf();
  final WB_Vector tmp=lZ.cross(_Z);
  if (!WB_Epsilon.isZeroSq(tmp.getSqLength())) {
    rotate(-Math.acos(_Z.dot(lZ)),tmp);
  }
 else   if (_Z.dot(lZ) < -1 + WB_Epsilon.EPSILON) {
    flipZ();
  }
  return this;
}

Fixed version (ground truth):
public WB_CoordinateSystem setZ(final double zx,final double zy,final double zz){
  final WB_Vector lZ=new WB_Vector(zx,zy,zz);
  lZ._normalizeSelf();
  final WB_Vector tmp=lZ.cross(_Z);
  if (!WB_Epsilon.isZeroSq(tmp.getSqLength())) {
    rotate(-Math.acos(WB_Math.clamp(_Z.dot(lZ),-1,1)),tmp);
  }
 else   if (_Z.dot(lZ) < -1 + WB_Epsilon.EPSILON) {
    flipZ();
  }
  return this;
}
Program: 30091
Project: 30091
Buggy source:
protected void set(final WB_Coordinate origin,final WB_Coordinate x,final WB_Coordinate y,final WB_Coordinate z,WB_CoordinateSystem CS){
  _origin=new WB_Point(origin);
  _X=new WB_Vector(x);
  _Y=new WB_Vector(y);
  _Z=new WB_Vector(z);
  _parent=CS;
}

Fixed version (ground truth):
protected void set(final WB_Coordinate origin,final WB_Coordinate x,final WB_Coordinate y,final WB_Coordinate z,final WB_CoordinateSystem CS){
  _origin=new WB_Point(origin);
  _X=new WB_Vector(x);
  _Y=new WB_Vector(y);
  _Z=new WB_Vector(z);
  _parent=CS;
}
Program: 30092
Project: 30092
Buggy source:
public double findSmallestSpanAroundStrut(final int i){
  final int n=struts.size();
  if ((i < 0) || (i >= n)) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  final ArrayList<WB_FrameNode> nnodes=getNeighbors();
  if (n == 1) {
    return 2 * Math.PI;
  }
 else   if (n == 2) {
    final WB_Vector u=nnodes.get(0).subToVector(this);
    final WB_Vector w=nnodes.get(1).subToVector(this);
    u._normalizeSelf();
    w._normalizeSelf();
    final double udw=u.dot(w);
    if (udw < WB_Epsilon.EPSILON - 1) {
      return Math.PI;
    }
 else {
      return Math.acos(udw);
    }
  }
 else {
    double minAngle=Double.MAX_VALUE;
    final WB_Vector u=nnodes.get(i).subToVector(this);
    u._normalizeSelf();
    for (int j=0; j < n; j++) {
      if (i != j) {
        final WB_Vector w=nnodes.get(j).subToVector(this);
        w._normalizeSelf();
        final double a=Math.acos(u.dot(w));
        minAngle=WB_Math.min(minAngle,a);
      }
    }
    return minAngle;
  }
}

Fixed version (ground truth):
public double findSmallestSpanAroundStrut(final int i){
  final int n=struts.size();
  if ((i < 0) || (i >= n)) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  final ArrayList<WB_FrameNode> nnodes=getNeighbors();
  if (n == 1) {
    return 2 * Math.PI;
  }
 else   if (n == 2) {
    final WB_Vector u=nnodes.get(0).subToVector(this);
    final WB_Vector w=nnodes.get(1).subToVector(this);
    u._normalizeSelf();
    w._normalizeSelf();
    final double udw=WB_Math.clamp(u.dot(w),-1,1);
    if (udw < WB_Epsilon.EPSILON - 1) {
      return Math.PI;
    }
 else {
      return Math.acos(udw);
    }
  }
 else {
    double minAngle=Double.MAX_VALUE;
    final WB_Vector u=nnodes.get(i).subToVector(this);
    u._normalizeSelf();
    for (int j=0; j < n; j++) {
      if (i != j) {
        final WB_Vector w=nnodes.get(j).subToVector(this);
        w._normalizeSelf();
        final double a=Math.acos(u.dot(w));
        minAngle=WB_Math.min(minAngle,a);
      }
    }
    return minAngle;
  }
}
Program: 30093
Project: 30093
Buggy source:
/** 
 * returns the smallest rotation angle (direction determined by vector dir) needed to bring point p on this circle to be on the circle c as well. Returns null if there is no intersection or just one intersection.
 * @return
 */
public Double getFirstIntersection(Circle c,Point p,Vector dir){
  double dist=center.distance(c.getCenter());
  if (dist > radius + c.getRadius() - WB_Epsilon.EPSILON)   return null;
  double r2d2=radius * radius + dist * dist;
  double rd2=2 * radius * dist;
  double cosAlpha=(r2d2 - c.getRadius() * c.getRadius()) / rd2;
  System.out.println("String_Node_Str" + cosAlpha + "String_Node_Str"+ Math.acos(cosAlpha));
  double distP2=p.distanceSquared(c.getCenter());
  double cosBeta=(r2d2 - distP2) / rd2;
  System.out.println("String_Node_Str" + cosAlpha + "String_Node_Str"+ Math.acos(cosBeta));
  Vector op=new Vector(center,p);
  Vector oco=new Vector(center,c.getCenter());
  Vector cr=op.crossNew(oco);
  cr.divideThis(op.length() * oco.length());
  double sinBeta=cr.length();
  double alpha=Math.acos(cosAlpha);
  System.out.println("String_Node_Str" + Math.toDegrees(cosAlpha));
  double beta=Math.atan2(sinBeta,cosBeta);
  System.out.println("String_Node_Str" + Math.toDegrees(beta));
  if (normal.dot(dir) > 0) {
    if (normal.dot(cr) > 0)     return beta - alpha;
 else     return 2 * Math.PI - beta - alpha;
  }
 else {
    if (normal.dot(cr) > 0)     return 2 * Math.PI - beta - alpha;
 else     return beta - alpha;
  }
}

Fixed version (ground truth):
/** 
 * returns the smallest rotation angle (direction determined by vector dir) needed to bring point p on this circle to be on the circle c as well. Returns null if there is no intersection or just one intersection.
 * @return smallest rotation angle
 */
public Double getFirstIntersection(Circle c,Point p,Vector dir){
  double dist=center.distance(c.getCenter());
  if (dist > radius + c.getRadius() - WB_Epsilon.EPSILON)   return null;
  double r2d2=radius * radius + dist * dist;
  double rd2=2 * radius * dist;
  double cosAlpha=(r2d2 - c.getRadius() * c.getRadius()) / rd2;
  System.out.println("String_Node_Str" + cosAlpha + "String_Node_Str"+ Math.acos(cosAlpha));
  double distP2=p.distanceSquared(c.getCenter());
  double cosBeta=(r2d2 - distP2) / rd2;
  System.out.println("String_Node_Str" + cosAlpha + "String_Node_Str"+ Math.acos(cosBeta));
  Vector op=new Vector(center,p);
  Vector oco=new Vector(center,c.getCenter());
  Vector cr=op.crossNew(oco);
  cr.divideThis(op.length() * oco.length());
  double sinBeta=cr.length();
  double alpha=Math.acos(cosAlpha);
  System.out.println("String_Node_Str" + Math.toDegrees(cosAlpha));
  double beta=Math.atan2(sinBeta,cosBeta);
  System.out.println("String_Node_Str" + Math.toDegrees(beta));
  if (normal.dot(dir) > 0) {
    if (normal.dot(cr) > 0)     return beta - alpha;
 else     return 2 * Math.PI - beta - alpha;
  }
 else {
    if (normal.dot(cr) > 0)     return 2 * Math.PI - beta - alpha;
 else     return beta - alpha;
  }
}
Program: 30094
Project: 30094
Buggy source:
/** 
 * LU Decomposition
 * @param A Rectangular matrix
 * @return Structure to access L, U and piv.
 */
public LUDecomposition(Matrix A){
  LU=A.clone().coords;
  m=A.getM();
  n=A.getN();
  piv=new int[m];
  for (int i=0; i < m; i++) {
    piv[i]=i;
  }
  pivsign=1;
  double[] LUrowi;
  double[] LUcolj=new double[m];
  for (int j=0; j < n; j++) {
    for (int i=0; i < m; i++) {
      LUcolj[i]=LU[i][j];
    }
    for (int i=0; i < m; i++) {
      LUrowi=LU[i];
      int kmax=Math.min(i,j);
      double s=0.0;
      for (int k=0; k < kmax; k++) {
        s+=LUrowi[k] * LUcolj[k];
      }
      LUrowi[j]=LUcolj[i]-=s;
    }
    int p=j;
    for (int i=j + 1; i < m; i++) {
      if (Math.abs(LUcolj[i]) > Math.abs(LUcolj[p])) {
        p=i;
      }
    }
    if (p != j) {
      for (int k=0; k < n; k++) {
        double t=LU[p][k];
        LU[p][k]=LU[j][k];
        LU[j][k]=t;
      }
      int k=piv[p];
      piv[p]=piv[j];
      piv[j]=k;
      pivsign=-pivsign;
    }
    if (j < m & LU[j][j] != 0.0) {
      for (int i=j + 1; i < m; i++) {
        LU[i][j]/=LU[j][j];
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * LU Decomposition
 * @param A Rectangular matrix
 */
public LUDecomposition(Matrix A){
  LU=A.clone().coords;
  m=A.getM();
  n=A.getN();
  piv=new int[m];
  for (int i=0; i < m; i++) {
    piv[i]=i;
  }
  pivsign=1;
  double[] LUrowi;
  double[] LUcolj=new double[m];
  for (int j=0; j < n; j++) {
    for (int i=0; i < m; i++) {
      LUcolj[i]=LU[i][j];
    }
    for (int i=0; i < m; i++) {
      LUrowi=LU[i];
      int kmax=Math.min(i,j);
      double s=0.0;
      for (int k=0; k < kmax; k++) {
        s+=LUrowi[k] * LUcolj[k];
      }
      LUrowi[j]=LUcolj[i]-=s;
    }
    int p=j;
    for (int i=j + 1; i < m; i++) {
      if (Math.abs(LUcolj[i]) > Math.abs(LUcolj[p])) {
        p=i;
      }
    }
    if (p != j) {
      for (int k=0; k < n; k++) {
        double t=LU[p][k];
        LU[p][k]=LU[j][k];
        LU[j][k]=t;
      }
      int k=piv[p];
      piv[p]=piv[j];
      piv[j]=k;
      pivsign=-pivsign;
    }
    if (j < m & LU[j][j] != 0.0) {
      for (int i=j + 1; i < m; i++) {
        LU[i][j]/=LU[j][j];
      }
    }
  }
}
Program: 30095
Project: 30095
Buggy source:
/** 
 * Gets the minimum squared distance to another line.
 * @see [Ericsson 05, p. 147]
 * @hop 14-32
 */
public double getSquaredDistance(Line l){
  double a=dir.getLengthSquared();
  double b=dir.dot(l.dir);
  double e=l.dir.getLengthSquared();
  double d=a * e - b * b;
  if (Math.abs(d) < WB_Epsilon.EPSILON)   return getDistanceSquared(l.p);
  Vector r=l.p.vectorTo(p);
  double c=dir.dot(r);
  double f=l.dir.dot(r);
  double s=(b * f - c * e) / d;
  double t=(a * f - b * c) / d;
  double dx=(p.x() + s * dir.x()) - (l.p.x() + t * l.dir.x());
  double dy=(p.y() + s * dir.y()) - (l.p.y() + t * l.dir.y());
  double dz=(p.z() + s * dir.z()) - (l.p.z() + t * l.dir.z());
  return dx * dx + dy * dy + dz * dz;
}

Fixed version (ground truth):
/** 
 * Gets the minimum squared distance to another line.
 */
public double getSquaredDistance(Line l){
  double a=dir.getLengthSquared();
  double b=dir.dot(l.dir);
  double e=l.dir.getLengthSquared();
  double d=a * e - b * b;
  if (Math.abs(d) < WB_Epsilon.EPSILON)   return getDistanceSquared(l.p);
  Vector r=l.p.vectorTo(p);
  double c=dir.dot(r);
  double f=l.dir.dot(r);
  double s=(b * f - c * e) / d;
  double t=(a * f - b * c) / d;
  double dx=(p.x() + s * dir.x()) - (l.p.x() + t * l.dir.x());
  double dy=(p.y() + s * dir.y()) - (l.p.y() + t * l.dir.y());
  double dz=(p.z() + s * dir.z()) - (l.p.z() + t * l.dir.z());
  return dx * dx + dy * dy + dz * dz;
}
Program: 30096
Project: 30096
Buggy source:
/** 
 * Check for symmetry, then construct the eigenvalue decomposition.
 * @param A Square matrix
 */
protected EigenvalueDecomposition(){
  double[][] A=coords;
  n=N;
  V=new double[n][n];
  d=new double[n];
  e=new double[n];
  issymmetric=true;
  for (int j=0; (j < n) & issymmetric; j++) {
    for (int i=0; (i < n) & issymmetric; i++) {
      issymmetric=(A[i][j] == A[j][i]);
    }
  }
  if (issymmetric) {
    for (int i=0; i < n; i++) {
      for (int j=0; j < n; j++) {
        V[i][j]=A[i][j];
      }
    }
    tred2();
    tql2();
  }
 else {
    H=new double[n][n];
    ort=new double[n];
    for (int j=0; j < n; j++) {
      for (int i=0; i < n; i++) {
        H[i][j]=A[i][j];
      }
    }
    orthes();
    hqr2();
  }
}

Fixed version (ground truth):
/** 
 * Check for symmetry, then construct the eigenvalue decomposition.
 */
protected EigenvalueDecomposition(){
  double[][] A=coords;
  n=N;
  V=new double[n][n];
  d=new double[n];
  e=new double[n];
  issymmetric=true;
  for (int j=0; (j < n) & issymmetric; j++) {
    for (int i=0; (i < n) & issymmetric; i++) {
      issymmetric=(A[i][j] == A[j][i]);
    }
  }
  if (issymmetric) {
    for (int i=0; i < n; i++) {
      for (int j=0; j < n; j++) {
        V[i][j]=A[i][j];
      }
    }
    tred2();
    tql2();
  }
 else {
    H=new double[n][n];
    ort=new double[n];
    for (int j=0; j < n; j++) {
      for (int i=0; i < n; i++) {
        H[i][j]=A[i][j];
      }
    }
    orthes();
    hqr2();
  }
}
Program: 30097
Project: 30097
Buggy source:
/** 
 * Get a submatrix.
 * @param r Array of row indices.
 * @param i0 Initial column index
 * @param i1 Final column index
 * @return A(r(:),j0:j1)
 * @exception ArrayIndexOutOfBoundsException Submatrix indices
 */
Matrix getMatrix(int[] r,int j0,int j1){
  Matrix X=new Matrix(r.length,j1 - j0 + 1);
  double[][] B=X.coords;
  try {
    for (int i=0; i < r.length; i++) {
      for (int j=j0; j <= j1; j++) {
        B[i][j - j0]=coords[r[i]][j];
      }
    }
  }
 catch (  ArrayIndexOutOfBoundsException e) {
    throw new ArrayIndexOutOfBoundsException("String_Node_Str");
  }
  return X;
}

Fixed version (ground truth):
/** 
 * Get a submatrix.
 * @param r Array of row indices.
 * @param j0 Initial column index
 * @param j1 Final column index
 * @return A(r(:),j0:j1)
 * @exception ArrayIndexOutOfBoundsException Submatrix indices
 */
Matrix getMatrix(int[] r,int j0,int j1){
  Matrix X=new Matrix(r.length,j1 - j0 + 1);
  double[][] B=X.coords;
  try {
    for (int i=0; i < r.length; i++) {
      for (int j=j0; j <= j1; j++) {
        B[i][j - j0]=coords[r[i]][j];
      }
    }
  }
 catch (  ArrayIndexOutOfBoundsException e) {
    throw new ArrayIndexOutOfBoundsException("String_Node_Str");
  }
  return X;
}