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 cout << "Standard Error: " << e.what() << " has occurred in the SLibshuff class Function evaluateAll. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
52 cout << "An unknown error has occurred in the SLibshuff class function evaluateAll. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
58 /***********************************************************************/
60 double SLibshuff::sCalculate(int x, int y){
63 minXY = getMinXY(x,y);
65 sort(minX.begin(), minX.end());
66 sort(minXY.begin(), minXY.end());
68 double sum = 0.0,t=0.0;
70 while( (ix < groupSizes[x]) && (iy < groupSizes[x]) ) {
71 double h = (ix-iy)/double(groupSizes[x]);
73 if(minX[ix] < minXY[iy]) {
74 sum += (minX[ix] - t)*h*h;
78 sum += (minXY[iy] - t)*h*h;
84 if(ix < groupSizes[x]) {
86 while(ix < groupSizes[x]) {
87 double h = (ix-iy)/double(groupSizes[x]);
88 sum += (minX[ix] - t)*h*h;
95 while(iy < groupSizes[x]) {
96 double h = (ix-iy)/double(groupSizes[x]);
97 sum += (minXY[iy] - t)*h*h;
105 catch(exception& e) {
106 cout << "Standard Error: " << e.what() << " has occurred in the SLibshuff class Function sCalculate. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
110 cout << "An unknown error has occurred in the SLibshuff class function sCalculate. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
116 /***********************************************************************/