First, for you to calculate the transposed of an "A" matrix, you need the "A" matrix. Another thing, for you to calculate the transpose of a matrix with the help of the function map(), you will need to implement an anonymous function (lambda). In this case, the code can be implemented as follows:
a = [[1, 2], [4, 6]]
transposta = list(map(lambda *i: [j for j in i], *a))
print(transposta)
Note that for this code I used the matrix:
a = [[1, 2], [4, 6]]
When executing this code, we receive as a result:
[[1, 4], [2, 6]]
Just to reinforce what has already been said in the other answer, matrices is a very long subject and we can have better results if we study libraries better numpy and scipy.
If you want to implement a def function to calculate the transpose of the matrix you can implement the following code:
def transposta(m):
return list(map(lambda *i: [j for j in i], *m))
matriz = [[1, 2], [4, 6]]
print(transposta(matriz))
Puts to us the declaration and settlement of
matrix
for us to test.– Augusto Vasques
If one of the answers below solved your problem and there was no doubt left, choose the one you liked the most and mark it as correct/accepted by clicking on the " " that is next to it, which also marks your question as solved. If you still have any questions or would like further clarification, feel free to comment.
– Lucas