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);
28 vector<vector<double> > dCXYValues(numGroups);
30 for(int i=0;i<numGroups;i++){
31 dCXYValues[i].resize(numGroups);
32 savedMins[i].resize(numGroups);
33 for(int j=0;j<numGroups;j++){
35 dCXYValues[i][j] = sCalculate(i,j);
36 savedMins[i][j] = minXY;
39 if(savedMins[i][i].size() == 0){
40 savedMins[i][i] = minX;
48 errorOut(e, "SLibshuff", "evaluateAll");
53 /***********************************************************************/
55 double SLibshuff::sCalculate(int x, int y){
58 minXY = getMinXY(x,y);
60 sort(minX.begin(), minX.end());
61 sort(minXY.begin(), minXY.end());
63 double sum = 0.0,t=0.0;
65 while( (ix < groupSizes[x]) && (iy < groupSizes[x]) ) {
66 double h = (ix-iy)/double(groupSizes[x]);
68 if(minX[ix] < minXY[iy]) {
69 sum += (minX[ix] - t)*h*h;
73 sum += (minXY[iy] - t)*h*h;
79 if(ix < groupSizes[x]) {
81 while(ix < groupSizes[x]) {
82 double h = (ix-iy)/double(groupSizes[x]);
83 sum += (minX[ix] - t)*h*h;
90 while(iy < groupSizes[x]) {
91 double h = (ix-iy)/double(groupSizes[x]);
92 sum += (minXY[iy] - t)*h*h;
100 catch(exception& e) {
101 errorOut(e, "SLibshuff", "sCalculate");
106 /***********************************************************************/