math4610

Routine Name: transpose

Author: David Merkley

Language: Python

Description/Purpose: Transposes matrix

Input: 1 matrix

Output: the transposition

Implementation/Code:

def transpose(A, doMutate=False):
    if doMutate:
        A = [[A[j][i] for j in range(len(A))] for i in range(len(A))]
        return A
    else:
        return [[A[j][i] for j in range(len(A))] for i in range(len(A))]