5 * Created by Pat Schloss on 4/8/09.
6 * Copyright 2009 Patrick D. Schloss. All rights reserved.
10 #include "slibshuff.h"
12 /***********************************************************************/
14 SLibshuff::SLibshuff(FullMatrix* D, int it, float co) : Libshuff(D, it, 0, co){}
16 /***********************************************************************/
18 float SLibshuff::evaluatePair(int i, int j){
19 return sCalculate(i,j);
22 /***********************************************************************/
24 vector<vector<double> > SLibshuff::evaluateAll(){
26 savedMins.resize(numGroups);
27 vector<vector<double> > dCXYValues(numGroups);
29 for(int i=0;i<numGroups;i++){
30 dCXYValues[i].resize(numGroups);
31 savedMins[i].resize(numGroups);
32 for(int j=0;j<numGroups;j++){
34 dCXYValues[i][j] = sCalculate(i,j);
35 savedMins[i][j] = minXY;
38 if(savedMins[i][i].size() == 0){
39 savedMins[i][i] = minX;
47 m->errorOut(e, "SLibshuff", "evaluateAll");
52 /***********************************************************************/
54 double SLibshuff::sCalculate(int x, int y){
56 double sum = 0.0,t=0.0;
60 if (m->control_pressed) { return sum; }
62 minXY = getMinXY(x,y);
64 if (m->control_pressed) { return sum; }
66 sort(minX.begin(), minX.end());
68 if (m->control_pressed) { return sum; }
70 sort(minXY.begin(), minXY.end());
72 if (m->control_pressed) { return sum; }
75 while( (ix < groupSizes[x]) && (iy < groupSizes[x]) ) {
76 double h = (ix-iy)/double(groupSizes[x]);
78 if(minX[ix] < minXY[iy]) {
79 sum += (minX[ix] - t)*h*h;
83 sum += (minXY[iy] - t)*h*h;
89 if(ix < groupSizes[x]) {
91 while(ix < groupSizes[x]) {
92 double h = (ix-iy)/double(groupSizes[x]);
93 sum += (minX[ix] - t)*h*h;
100 while(iy < groupSizes[x]) {
101 double h = (ix-iy)/double(groupSizes[x]);
102 sum += (minXY[iy] - t)*h*h;
110 catch(exception& e) {
111 m->errorOut(e, "SLibshuff", "sCalculate");
116 /***********************************************************************/