X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=weighted.cpp;h=49bf6bf1fd2a2053ed7f3f7e0ea30fb5595400a0;hb=250e3b11b1c9c1e1ad458ab6c7e71ac2e67e11d9;hp=b0d06fb0078e0201975e7738d1321e7932230253;hpb=2cfb747aa8f63bde9c1114001e6d2e81ccd26178;p=mothur.git diff --git a/weighted.cpp b/weighted.cpp index b0d06fb..49bf6bf 100644 --- a/weighted.cpp +++ b/weighted.cpp @@ -36,13 +36,14 @@ EstOutput Weighted::getValues(Tree* t, int p, string o) { } } - 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);