0
有兩個矩陣X和M和我需要獲得下列矩陣dMATLAB量化和避免環路
m = 20; n = 10;
X = rand(m,n);
M = rand(m,m);
M = (M + M')/2;
D = zeros(n,n);
for i = 1:n
for j = 1:n
D(i,j) = X(:,i)'*M*X(:,j);
end
end
當n和m是大,d的計算是很慢的。有什麼方法可以加快速度?
只是做'X'* M * X'? – Divakar