]> git.donarmstrong.com Git - mothur.git/blob - structeuclidean.cpp
changes while testing
[mothur.git] / structeuclidean.cpp
1 /*
2  *  structeuclidean.cpp
3  *  Mothur
4  *
5  *  Created by westcott on 12/14/10.
6  *  Copyright 2010 Schloss Lab. All rights reserved.
7  *
8  */
9
10 #include "structeuclidean.h"
11
12 /***********************************************************************/
13 EstOutput StructEuclidean::getValues(vector<SharedRAbundVector*> shared) {
14         try {
15                 data.resize(1,0);
16                 
17                 double sum = 0.0;
18                 
19                 for (int i = 0; i < shared[0]->getNumBins(); i++) { 
20                         
21                         int Aij = shared[0]->getAbundance(i);
22                         int Bij = shared[1]->getAbundance(i);
23                         
24                         //(Aij - Bij) ^ 2
25                         sum += ((Aij - Bij) * (Aij - Bij));
26                 }
27                 
28                 data[0] = sqrt(sum);
29                 
30                 if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
31                 
32                 return data;
33         }
34         catch(exception& e) {
35                 m->errorOut(e, "StructEuclidean", "getValues");
36                 exit(1);
37         }
38 }
39 /***********************************************************************/
40