[ edit ]

# ===== 【関数定義】 転置行列を生成し,返す
def transpose_matrix( matrix ):
    m = len( matrix )
    n = len( matrix[0] )
    result_matrix = create_zero_matrix( n, m )
    for x in range( m ):
        for y in range( n ):
            result_matrix[y][x] = matrix[x][y]
    return( result_matrix )

# ===== 【関数定義】 m行n列の行列を二重リストで生成する(要素はすべてゼロ)
def create_zero_matrix( m, n ):
    matrix = list()
    for x in range( m ):
        matrix.append( [0]*n )
    return( matrix )

SoftEng: Python/Prog/Practice/Basic/03/BP_006a/Digest (last edited 2019-10-30 17:07:48 by TadashiIijima)