Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我试图让标题说明一切。
我有一个矩阵,我需要计算列组合的外积的总和。我知道如何使用 for 循环来做到这一点。但是,有没有一种矢量化的方式来做到这一点?
testData = rand(x); answer = zeros(x); for i=1:x for j=1:x answer = answer + testData(:,i)'*testData(:,j); end end
答案就在这个问题Fast Outer Product
answer = testData.'*testData;
注意 这给出了行的外积的总和。