필터 지우기
필터 지우기

reducing number of operations in matrix multiplication

조회 수: 1 (최근 30일)
Douglas Brenner
Douglas Brenner 2018년 10월 10일
답변: Douglas Brenner 2018년 10월 11일
I want to perform the follow operation: synch = spect1(1:num_pts ,2)*spect2(1:num_pts,2)'; The problem is that num_pts > 300,000. Would take too long. Fortunately, I don't need the entire output. I only need the diagonal elements plus elements from the say 10 adjacent diagonals on either side. Anybody know how to do this or want to take a guess? Thanks

답변 (2개)

Douglas Brenner
Douglas Brenner 2018년 10월 11일
편집: Torsten 2018년 10월 11일
testm = [1,2,3,4,5;2,4,5,7,10]
num_pts = 5;
testm = transpose(testm)
corr = testm(:,2)*testm(:,2)'
diag(corr)
main_diag = testm(:,2).*testm(:,2)
for i=1:3
diags1{i} = testm(i+1:num_pts ,2).*testm(1:num_pts-i-1,2);
diags2{i} = testm(i+1:num_pts ,2).*testm(1:num_pts-i-1,2);
end
failed at diags1{i} = testm(i+1:num_pts ,2).*testm(1:num_pts-i-1,2); Error using .* Matrix dimensions must agree. Error in test (line 8) diags1{i} = testm(i+1:num_pts ,2).*testm(1:num_pts-i-1,2);
Got to run.
  댓글 수: 1
Torsten
Torsten 2018년 10월 11일
The number of elements of testm(i+1:num_pts,2) and testm(1:num_pts-i-1,2) are not the same ...

댓글을 달려면 로그인하십시오.


Douglas Brenner
Douglas Brenner 2018년 10월 11일
Clearly but that was the suggested solution. Trying for i=1:2 diags1{i} = testm(i+1:num_pts-i-1 ,2).*testm(1:num_pts-i-1,2); diags2{i} = testm(i+1:num_pts-i-1 ,2).*testm(1:num_pts-i-1,2); end
gives the same error as does other attempts to fix it

카테고리

Help CenterFile Exchange에서 Operating on Diagonal Matrices에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by