this.av =av;
this.aa = aa;
this.cm=cm;
+ calculate(cm);
+
+ }
+ public void calculate(ContactMatrixI cm)
+ {
+ this.cm = cm;
node = new Vector<BinaryNode>();
clusters = new Vector<BitSet>();
distances = new Matrix(new double[cm.getWidth()][cm.getWidth()]);
noseqs=cm.getWidth();
done = new BitSet();
+ double moduli[]=new double[cm.getWidth()];
+
+
for (int i=0;i<cm.getWidth();i++)
{
// init the tree engine node for this column
// compute distance matrix element
ContactListI ith=cm.getContactList(i);
+
for (int j=0;j<i;j++)
{
+ distances.setValue(i,i,0);
ContactListI jth = cm.getContactList(j);
double prd=0;
for (int indx=0;indx<cm.getHeight();indx++)
{
+ if (j==0)
+ {
+ moduli[i]+=ith.getContactAt(indx)*ith.getContactAt(indx);
+ }
prd+=ith.getContactAt(indx)*jth.getContactAt(indx);
}
- distances.setValue(i, j, prd);
- distances.setValue(j, i, prd);
+ if (j==0)
+ {
+ moduli[i]=Math.sqrt(moduli[i]);
+ }
+ prd=(moduli[i]!=0 && moduli[j]!=0) ? prd/(moduli[i]*moduli[j]) : 0;
+ distances.setValue(i, j, 1-prd);
+ distances.setValue(j, i, 1-prd);
}
}
noClus = clusters.size();
cluster();
-
}
/**
* Calculates and saves the distance between the combination of cluster(i) and