如何在 Octave 中仅计算矩阵乘积的对角线?
Octave 有没有办法只计算和存储矩阵乘积的对角线?
基本上就像这样做:vector = diag(A*B);
除了对角线上的值之外,我不关心A*B
的任何值。矩阵大小约为 80k x 12
和 12 x 80k
,因此即使我不关心速度/额外内存,它也根本不适合 RAM。
奇怪的是,由于 Octave 是一个针对巨大数据集的包,并且对角线非常重要,所以它应该是可能的。
Is there a way in Octave to compute and store only the diagonal of a matrix product?
Basically like doing: vector = diag(A*B);
I don't care about any of the values of A*B
except those on the diagonal. The matrix sizes are around 80k x 12
and 12 x 80k
, so even if I didn't care about the speed/extra memory it simply wont fit in RAM.
Strange, since Octave is a package for huge data sets and diagonals are very important, so it should be possible.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对角线中的第一个元素是 A 的第一行与 B 的第一列的标量积。对角线中的第二个元素是 A 的第二行与 B 的第二列的标量积。
换句话说:
The first element in the diagonal is the scalar product of the first row of A with the first column of B. The second element in the diagonal is the scalar product of the second row of A with the second column of B.
In other words:
您可以在 MATLAB 中执行此操作(可能类似于 Octave 语法):
这将仅将运算
A*B
的结果对角线计算为列向量vector
。This is how you could do it in MATLAB (probably similar to Octave syntax):
This will compute only the resulting diagonal of the operation
A*B
as a column vectorvector
.实际上我认为它是 A 的第一行与 B 的第一列的点积...第二个对角线元素是第二行和第二列的点积...等等
actually I think it's the dot product of the first row of A with the first column of B... the second diagonal element is the dot product of the second row and the second column... etc