numpy矩阵转置只需要这样子:

import numpy as np

import fractions

# 设置以分数形式显示
np.set_printoptions(formatter={'all': lambda x: str(fractions.Fraction(x).limit_denominator())})
# 定义矩阵
c = np.array([[-1/np.sqrt(2), 0, 1/np.sqrt(2)], [0, 1, 0], [1/np.sqrt(2), 0, 1/np.sqrt(2)]])
# 矩阵转置
ct = c.T
print(ct)

你也可能喜欢

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注