def transpose(A):
    """
    return a list of lists for a Matrix A ( list of lists )
    with transposed representation of A
    """
    m = len(A)
    if m == 0:
        return []
    n = len(A[0])
    out = [[0.0 for x in range(m)] for y in range(n)]
    for r in range(m):
        for c in range(n):
            out[c][r] = A[r][c]
    return out