5 * Created by Pat Schloss on 4/8/09.
6 * Copyright 2009 Patrick D. Schloss. All rights reserved.
10 #include "dlibshuff.h"
12 /***********************************************************************/
14 DLibshuff::DLibshuff(FullMatrix* D, int it, float step, float co) : Libshuff(D, it, step, co){
16 numDXs = int(cutOff / stepSize);
20 /***********************************************************************/
22 float DLibshuff::evaluatePair(int i, int j){
23 return dCalculate(i,j);
26 /***********************************************************************/
28 vector<vector<double> > DLibshuff::evaluateAll(){
29 savedMins.resize(numGroups);
30 vector<vector<double> > dCXYValues(numGroups);
32 for(int i=0;i<numGroups;i++){
33 savedMins[i].resize(numGroups);
34 dCXYValues[i].resize(numGroups);
35 for(int j=0;j<numGroups;j++){
36 if(i!=j){ dCXYValues[i][j] = dCalculate(i,j); }
37 savedMins[i][i] = minX;
38 savedMins[i][j] = minXY;
45 /***********************************************************************/
47 double DLibshuff::dCalculate(int x, int y){
53 if (m->control_pressed) { return sum; }
55 minXY = getMinXY(x, y);
57 if (m->control_pressed) { return sum; }
59 vector<int> nx = calcN(minX);
61 if (m->control_pressed) { return sum; }
63 vector<int> nxy = calcN(minXY);
65 if (m->control_pressed) { return sum; }
67 for(int i=0;i<numDXs;i++){
68 float h = (nx[i] - nxy[i]) / (float) groupSizes[x];
69 sum += h * h * stepSize;
75 /***********************************************************************/
77 vector<int> DLibshuff::calcN(vector<double> minVector){
79 vector<int> counts(numDXs,0);
81 int precision = int(1 / stepSize);
83 for(int i=0;i<minVector.size();i++){
84 int bin = int (precision * minVector[i]);
85 if(bin < numDXs){ counts[bin]++; }
88 for(int i=1;i<numDXs;i++){
89 counts[i] += counts[i-1];
95 /***********************************************************************/