]> git.donarmstrong.com Git - mothur.git/blobdiff - unweighted.cpp
fixes while testing 1.33.0
[mothur.git] / unweighted.cpp
index a845f9bc2fa54a5c27b0d74aed20929f1aeb756f..8fbd9d2fd64a90504e083f62418a54c40e8e26e1 100644 (file)
@@ -51,13 +51,14 @@ EstOutput Unweighted::getValues(Tree* t, int p, string o) {
                }
         
         lines.clear();
-        int numPairs = namesOfGroupCombos.size();
-        int numPairsPerProcessor = numPairs / processors;
-        
-        for (int i = 0; i < processors; i++) {
-            int startPos = i * numPairsPerProcessor;
-            if(i == processors - 1){ numPairsPerProcessor = numPairs - i * numPairsPerProcessor; }
-            lines.push_back(linePair(startPos, numPairsPerProcessor));
+        int remainingPairs = namesOfGroupCombos.size();
+        int startIndex = 0;
+        for (int remainingProcessors = processors; remainingProcessors > 0; remainingProcessors--) {
+            int numPairs = remainingPairs; //case for last processor
+            if (remainingProcessors != 1) { numPairs = ceil(remainingPairs / remainingProcessors); }
+            lines.push_back(linePair(startIndex, numPairs)); //startIndex, numPairs
+            startIndex = startIndex + numPairs;
+            remainingPairs = remainingPairs - numPairs;
         }
         
         data = createProcesses(t, namesOfGroupCombos, ct);
@@ -316,7 +317,7 @@ EstOutput Unweighted::getValues(Tree* t, string groupA, string groupB, int p, st
      
         lines.clear();
         int numPairs = namesOfGroupCombos.size();
-        int numPairsPerProcessor = numPairs / processors;
+        int numPairsPerProcessor = ceil(numPairs / processors);
      
         for (int i = 0; i < processors; i++) {
             int startPos = i * numPairsPerProcessor;