Problem: Write an OpenMP program to transpose a given matrix. The input for this
ID: 3651661 • Letter: P
Question
Problem: Write an OpenMP program to transpose a given matrix. Theinput for this program will be from a text file. The name of the file
will be matrix.txt and will be in your pgm directory. In the above
example the matrix.txt file would be:
3 3
1 2 8
3 4 3
5 6 1
Example Output:
1 3 5
2 4 6
What I have below is in pseudocode but I do not know how to convert it to C++ and I am not sure if this is correct for this problem.
procedure transpose_matrix (matrix)
result := []
# for each column
every (i := 1 to *matrix[1]) do {
col := []
# extract the number in each row for that column
every (row := !matrix) do put (col, row[i])
# and push that column as a row in the result matrix
put (result, col)
}
return result
end
procedure print_matrix (matrix)
every (row := !matrix) do {
every writes (!row || " ")
write ()
}
end
procedure main ()
matrix := [[1,2,3],[4,5,6]]
write ("Start:")
print_matrix (matrix)
transposed := transpose_matrix (matrix)
write ("Transposed:")
print_matrix (transposed)
end