This commit is contained in:
2020-03-29 20:23:48 -06:00
parent 45f960649b
commit 6a940a7519
2 changed files with 6 additions and 2 deletions

View File

@@ -7,12 +7,12 @@
namespace matrixTools namespace matrixTools
{ {
template <typename T> template <typename T>
std::vector<std::vector<T>> UnflattenMatrix(std::vector<T> origianlVector, int rowSize, int columnSize) std::vector<std::vector<T>> UnflattenMatrix(std::vector<T> originalVector, int rowSize, int columnSize)
{ {
std::vector<std::vector<T>> matrix(columnSize, std::vector<T>(rowSize, 0)); std::vector<std::vector<T>> matrix(columnSize, std::vector<T>(rowSize, 0));
for (int i = 0; i < columnSize; i++) { for (int i = 0; i < columnSize; i++) {
for (int j = 0; j < rowSize; j++) { for (int j = 0; j < rowSize; j++) {
matrix[i][j] = origianlVector[i + j]; matrix[i][j] = originalVector[i + j];
} }
} }
return matrix; return matrix;

View File

@@ -29,6 +29,10 @@ int main(int argc, char* argv[])
std::cout << std::endl; std::cout << std::endl;
} }
flatMatrix = matrixTools::FlattenMatrix(matrix); flatMatrix = matrixTools::FlattenMatrix(matrix);
for(int i = 0; i < flatMatrix.size(); i++){
std::cout << flatMatrix[i] << " ";
}
std::cout<<std::endl;
} }
MPI_Bcast(&citiesSize, 1, MPI_INT, 0, MPI_COMM_WORLD); MPI_Bcast(&citiesSize, 1, MPI_INT, 0, MPI_COMM_WORLD);
if(rank){ if(rank){