独立滚动矩阵行

独立滚动矩阵行,第1张

独立滚动矩阵

确保您可以使用高级索引来做到这一点,这是否是最快的方法可能取决于您的数组大小(如果行很大,则可能不是):

rows, column_indices = np.ogrid[:A.shape[0], :A.shape[1]]# Use always a negative shift, so that column_indices are valid.# (could also use module operation)r[r < 0] += A.shape[1]column_indices = column_indices - r[:, np.newaxis]result = A[rows, column_indices]


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5632240.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-15
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存