Effacer les filtres
Effacer les filtres

reducing number of operations in matrix multiplication

1 vue (au cours des 30 derniers jours)
Douglas Brenner
Douglas Brenner le 10 Oct 2018
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

Réponses (2)

Douglas Brenner
Douglas Brenner le 11 Oct 2018
Modifié(e) : Torsten le 11 Oct 2018
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 commentaire
Torsten
Torsten le 11 Oct 2018
The number of elements of testm(i+1:num_pts,2) and testm(1:num_pts-i-1,2) are not the same ...

Connectez-vous pour commenter.


Douglas Brenner
Douglas Brenner le 11 Oct 2018
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

Catégories

En savoir plus sur Operating on Diagonal Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by