Program: 58771
Project: 58771
Buggy source:
/** 
 * Calculates the similarity matrix for a given set and VA�s
 * @param set
 * @param iVAIdContent
 * @param iVAIdStorage
 * @return
 */
public void determineSimilarities(ISet set,Integer iVAIdContent,Integer iVAIdStorage,EClustererType eClustererType){
  this.iVAIdContent=iVAIdContent;
  this.iVAIdStorage=iVAIdStorage;
  IVirtualArray contentVA=set.getVA(iVAIdContent);
  IVirtualArray storageVA=set.getVA(iVAIdStorage);
  IDistanceMeasure distanceMeasure;
  if (eDistanceMeasure == EDistanceMeasure.EUCLIDEAN_DISTANCE)   distanceMeasure=new EuclideanDistance();
 else   distanceMeasure=new PearsonCorrelation();
  if (eClustererType == EClustererType.GENE_CLUSTERING) {
    if (contentVA.get(0) == 0)     bStart0=true;
 else     bStart0=false;
    int iNrElements=contentVA.size();
    pbSimilarity.setMinimum(0);
    pbSimilarity.setMaximum(iNrElements);
    float[] dArInstance1=new float[storageVA.size()];
    float[] dArInstance2=new float[storageVA.size()];
    int icnt1=0, icnt2=0, isto=0;
    int count=0;
    for (    Integer iContentIndex1 : contentVA) {
      pbSimilarity.setSelection(icnt1);
      shell.update();
      isto=0;
      for (      Integer iStorageIndex1 : storageVA) {
        dArInstance1[isto]=set.get(iStorageIndex1).getFloat(EDataRepresentation.NORMALIZED,iContentIndex1);
        isto++;
      }
      icnt2=0;
      for (      Integer iContentIndex2 : contentVA) {
        isto=0;
        for (        Integer iStorageIndex2 : storageVA) {
          dArInstance2[isto]=set.get(iStorageIndex2).getFloat(EDataRepresentation.NORMALIZED,iContentIndex2);
          isto++;
        }
        if (icnt1 != icnt2) {
          s[count]=-distanceMeasure.getMeasure(dArInstance1,dArInstance2);
          if (bStart0 == true) {
            i[count]=iContentIndex1;
            k[count]=iContentIndex2;
          }
 else {
            i[count]=iContentIndex1 - 1;
            k[count]=iContentIndex2 - 1;
          }
          count++;
        }
        icnt2++;
      }
      icnt1++;
    }
    float median=ClusterHelper.median(s);
    for (    Integer iContentIndex1 : contentVA) {
      s[count]=median * fClusterFactor;
      if (bStart0 == true) {
        i[count]=iContentIndex1;
        k[count]=iContentIndex1;
      }
 else {
        i[count]=iContentIndex1 - 1;
        k[count]=iContentIndex1 - 1;
      }
      count++;
    }
  }
 else {
    if (storageVA.get(0) == 0)     bStart0=true;
 else     bStart0=false;
    int iNrElements=storageVA.size();
    pbSimilarity.setMinimum(0);
    pbSimilarity.setMaximum(iNrElements);
    float[] dArInstance1=new float[contentVA.size()];
    float[] dArInstance2=new float[contentVA.size()];
    int icnt1=0, icnt2=0, isto=0;
    int count=0;
    for (    Integer iStorageIndex1 : storageVA) {
      pbSimilarity.setSelection(icnt1);
      shell.update();
      isto=0;
      for (      Integer iContentIndex1 : contentVA) {
        dArInstance1[isto]=set.get(iStorageIndex1).getFloat(EDataRepresentation.NORMALIZED,iContentIndex1);
        isto++;
      }
      icnt2=0;
      for (      Integer iStorageIndex2 : storageVA) {
        isto=0;
        for (        Integer iContentIndex2 : contentVA) {
          dArInstance2[isto]=set.get(iStorageIndex2).getFloat(EDataRepresentation.NORMALIZED,iContentIndex2);
          isto++;
        }
        if (icnt1 != icnt2) {
          s[count]=-distanceMeasure.getMeasure(dArInstance1,dArInstance2);
          if (bStart0 == true) {
            i[count]=iStorageIndex1;
            k[count]=iStorageIndex2;
          }
 else {
            i[count]=iStorageIndex1 - 1;
            k[count]=iStorageIndex2 - 1;
          }
          count++;
        }
        icnt2++;
      }
      icnt1++;
    }
    float median=ClusterHelper.median(s);
    for (    Integer iStorageIndex1 : storageVA) {
      s[count]=median * fClusterFactor;
      if (bStart0 == true) {
        i[count]=iStorageIndex1;
        k[count]=iStorageIndex1;
      }
 else {
        i[count]=iStorageIndex1 - 1;
        k[count]=iStorageIndex1 - 1;
      }
      count++;
    }
  }
}

Fixed version (ground truth):
/** 
 * Calculates the similarity matrix for a given set and VA�s
 * @param set
 * @param iVAIdContent
 * @param iVAIdStorage
 * @return
 */
public void determineSimilarities(ISet set,Integer iVAIdContent,Integer iVAIdStorage,EClustererType eClustererType){
  this.iVAIdContent=iVAIdContent;
  this.iVAIdStorage=iVAIdStorage;
  IVirtualArray contentVA=set.getVA(iVAIdContent);
  IVirtualArray storageVA=set.getVA(iVAIdStorage);
  IDistanceMeasure distanceMeasure;
  if (eDistanceMeasure == EDistanceMeasure.EUCLIDEAN_DISTANCE)   distanceMeasure=new EuclideanDistance();
 else   distanceMeasure=new PearsonCorrelation();
  if (eClustererType == EClustererType.GENE_CLUSTERING) {
    int iNrElements=contentVA.size();
    pbSimilarity.setMinimum(0);
    pbSimilarity.setMaximum(iNrElements);
    float[] dArInstance1=new float[storageVA.size()];
    float[] dArInstance2=new float[storageVA.size()];
    int icnt1=0, icnt2=0, isto=0;
    int count=0;
    for (    Integer iContentIndex1 : contentVA) {
      pbSimilarity.setSelection(icnt1);
      shell.update();
      isto=0;
      for (      Integer iStorageIndex1 : storageVA) {
        dArInstance1[isto]=set.get(iStorageIndex1).getFloat(EDataRepresentation.NORMALIZED,iContentIndex1);
        isto++;
      }
      icnt2=0;
      for (      Integer iContentIndex2 : contentVA) {
        isto=0;
        for (        Integer iStorageIndex2 : storageVA) {
          dArInstance2[isto]=set.get(iStorageIndex2).getFloat(EDataRepresentation.NORMALIZED,iContentIndex2);
          isto++;
        }
        if (icnt1 != icnt2) {
          s[count]=-distanceMeasure.getMeasure(dArInstance1,dArInstance2);
          i[count]=icnt1;
          k[count]=icnt2;
          count++;
        }
        icnt2++;
      }
      icnt1++;
    }
    float median=ClusterHelper.median(s);
    int cnt=0;
    for (    Integer iContentIndex1 : contentVA) {
      s[count]=median * fClusterFactor;
      i[count]=cnt;
      k[count]=cnt;
      count++;
      cnt++;
    }
  }
 else {
    int iNrElements=storageVA.size();
    pbSimilarity.setMinimum(0);
    pbSimilarity.setMaximum(iNrElements);
    float[] dArInstance1=new float[contentVA.size()];
    float[] dArInstance2=new float[contentVA.size()];
    int isto1=0, isto2=0, icnt=0;
    int count=0;
    for (    Integer iStorageIndex1 : storageVA) {
      pbSimilarity.setSelection(isto1);
      shell.update();
      icnt=0;
      for (      Integer iContentIndex1 : contentVA) {
        dArInstance1[icnt]=set.get(iStorageIndex1).getFloat(EDataRepresentation.NORMALIZED,iContentIndex1);
        icnt++;
      }
      isto2=0;
      for (      Integer iStorageIndex2 : storageVA) {
        icnt=0;
        for (        Integer iContentIndex2 : contentVA) {
          dArInstance2[icnt]=set.get(iStorageIndex2).getFloat(EDataRepresentation.NORMALIZED,iContentIndex2);
          icnt++;
        }
        if (isto1 != isto2) {
          s[count]=-distanceMeasure.getMeasure(dArInstance1,dArInstance2);
          i[count]=isto1;
          k[count]=isto2;
          count++;
        }
        isto2++;
      }
      isto1++;
    }
    float median=ClusterHelper.median(s);
    int sto=0;
    for (    Integer iStorageIndex1 : storageVA) {
      s[count]=median * fClusterFactor;
      i[count]=sto;
      k[count]=sto;
      count++;
      sto++;
    }
  }
}