(Python)提取(AB)的对角线块部分的有效方法,而无需进行矩阵乘法AB
假设A是1000x50矩阵,B是50x100矩阵。然后AB是尺寸为1000x100的矩阵。我正在执行一个任务,该任务试图获得AB的对角线块(实际上是对角上的列矢量)。具体来说,我想提取[0:10,0],a [10:20,1],a [20:30,2],...,A [990:1000,99]。
但是,我想避免计算AB。我在AB的列中尝试了“循环”,但它非常慢。是否还有其他有效的实施方法?
Suppose A is 1000x50 matrix and B is a 50x100 matrix. Then AB is a matrix of size 1000x100. I'm doing a task which tries to get the diagonal block (actually column vectors on the diagonal) of AB. Specifically, I'd like to extract A[0:10,0],A[10:20,1],A[20:30,2],...,A[990:1000,99].
However, I would like to avoid calculating AB. I tried "for loop" in columns of AB but it is very slow. Is there any other efficient way to implement this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论