X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=rabundvector.cpp;h=1613f0a16c3c868680a637b405e546abb2031932;hb=dc874a77f24b3808775e2ce7e39595c647a07f82;hp=d6b7d1225691e9287c94679317fa2ece34caf158;hpb=bfbc55964f1977da72c2cea984288a427d370a59;p=mothur.git diff --git a/rabundvector.cpp b/rabundvector.cpp index d6b7d12..1613f0a 100644 --- a/rabundvector.cpp +++ b/rabundvector.cpp @@ -8,11 +8,10 @@ */ using namespace std; - -#include "utilities.hpp" #include "rabundvector.hpp" #include "sabundvector.hpp" #include "ordervector.hpp" +#include "calculator.h" /***********************************************************************/ @@ -52,6 +51,26 @@ RAbundVector::RAbundVector(string id, vector rav) : DataVector(id), data(ra } } +/***********************************************************************/ + +RAbundVector::RAbundVector(vector rav, int mr, int nb, int ns) { + try { + numBins = nb; + maxRank = mr; + numSeqs = ns; + data = rav; + } + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the RAbundVector class Function RAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the RAbundVector class function RAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } +} + + /***********************************************************************/ @@ -160,6 +179,33 @@ int RAbundVector::size(){ /***********************************************************************/ +void RAbundVector::quicksort(){ + sort(data.rbegin(), data.rend()); +} + +/***********************************************************************/ + +int RAbundVector::sum(){ + VecCalc vecCalc; + return vecCalc.sumElements(data); +} + +/***********************************************************************/ + +int RAbundVector::sum(int index){ + VecCalc vecCalc; + return vecCalc.sumElements(data, index); +} + +/***********************************************************************/ + +int RAbundVector::numNZ(){ + VecCalc vecCalc; + return vecCalc.numNZ(data); +} + +/***********************************************************************/ + vector::reverse_iterator RAbundVector::rbegin(){ return data.rbegin(); }