From 7f8febb78fa6e9c132d8f0f93ca09bddb8d935f5 Mon Sep 17 00:00:00 2001 From: bbod Date: Mon, 30 Mar 2020 18:00:02 -0600 Subject: [PATCH] Auto Commit --- HW10/MakePermutationMatrix.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/HW10/MakePermutationMatrix.cpp b/HW10/MakePermutationMatrix.cpp index d94d4fa..b1edefb 100644 --- a/HW10/MakePermutationMatrix.cpp +++ b/HW10/MakePermutationMatrix.cpp @@ -10,10 +10,19 @@ std::vector MakePermutationMatrix::MakePermutation(std::vector source, int rank, int size, std::vector> costMatrix){ std::vector returnVector; std::vector localCostVector; + std::size_t offset; std::sort(source.begin(), source.end()); std::vector myPerm = source; std::vector nextPerm = source; - auto offset = (myPerm.size()+1)/size; + + if(!rank){ + size_t totalNumPermutations = 1; + for(size_t i = 1; i <= source.size(); i++) + totalNumPermutations *= i; + offset = totalNumPermutations/size; + } + MPI_Bcast(&offset, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD); + //return vector should be the size of number of processors as they are going to only return their own smallest. if(rank)