reducing number of operations in matrix multiplication

2 visualizaciones (últimos 30 días)
Douglas Brenner
Douglas Brenner el 10 de Oct. de 2018
Respondida: Douglas Brenner el 11 de Oct. de 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

Respuestas (2)

Douglas Brenner
Douglas Brenner el 11 de Oct. de 2018
Editada: Torsten el 11 de Oct. de 2018
testm = [1,2,3,4,5;2,4,5,7,10]
num_pts = 5;
testm = transpose(testm)
corr = testm(:,2)*testm(:,2)'
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);
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 comentario
Torsten el 11 de Oct. de 2018
The number of elements of testm(i+1:num_pts,2) and testm(1:num_pts-i-1,2) are not the same ...

Iniciar sesión para comentar.

Douglas Brenner
Douglas Brenner el 11 de Oct. de 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


Más información sobre Operating on Diagonal Matrices en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by