]> git.donarmstrong.com Git - mothur.git/blob - memeuclidean.cpp
mods in testing 1.16.0
[mothur.git] / memeuclidean.cpp
1 /*
2  *  memeuclidean.cpp
3  *  Mothur
4  *
5  *  Created by westcott on 12/17/10.
6  *  Copyright 2010 Schloss Lab. All rights reserved.
7  *
8  */
9
10 #include "memeuclidean.h"
11
12 /***********************************************************************/
13 EstOutput MemEuclidean::getValues(vector<SharedRAbundVector*> shared) {
14         try {
15                 data.resize(1,0);
16                 
17                 double sum = 0.0;
18                 for (int i = 0; i < shared[0]->getNumBins(); i++) {
19                         int A = shared[0]->getAbundance(i);
20                         int B = shared[1]->getAbundance(i);
21                         
22                         if (A > 0) { A = 1; }
23                         if (B > 0) { B = 1; }
24                         
25                         sum += ((A-B)*(A-B));
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, "MemEuclidean", "getValues");
36                 exit(1);
37         }
38 }
39 /***********************************************************************/
40