X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=rabundvector.cpp;fp=rabundvector.cpp;h=6b0a048cabd5748107c070405efe8df7c09cdafa;hb=eb1c88346fb246e95a6b38935b103f95e38b82ca;hp=d6b7d1225691e9287c94679317fa2ece34caf158;hpb=d53f63d7e0d9c3feeb8ded5a74e6c150fae50fe9;p=mothur.git diff --git a/rabundvector.cpp b/rabundvector.cpp index d6b7d12..6b0a048 100644 --- a/rabundvector.cpp +++ b/rabundvector.cpp @@ -13,6 +13,7 @@ using namespace std; #include "rabundvector.hpp" #include "sabundvector.hpp" #include "ordervector.hpp" +#include "calculator.h" /***********************************************************************/ @@ -52,6 +53,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 +181,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(); }