热线电话:13121318867

登录
2019-01-30 阅读量: 836
python numpy 矩阵行交换 无效

python numpy 矩阵行交换 无效

>>> import numpy as np
>>> A = np.mat('1 2;3 4')
>>> A
matrix([[1, 2],
[3, 4]])
>>> A[0],A[1] = A[1],A[0]
>>> A
matrix([[3, 4],
[3, 4]])
>>>

为什么交换无效?

答;这样写:

A[[0,1]] = A[[1,0]]
// 上面相当于 A[[0,1],:] = A[[1,0],:]
0.0000
3
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子