How can I faster matrix multiplication

5 Ansichten (letzte 30 Tage)
Paul
Paul am 26 Feb. 2020
Bearbeitet: KALYAN ACHARJYA am 27 Feb. 2020
Hello, first time here to ask
I have a 3 by 3 matrix, say G. And I also have a row vector, R.
What I need is finding R * G * R.'
but it is running very slow.
It used around 84.5s to have it call 26800 times.
Is that normal? Or how can I speed up since I have to do it inside a nested for loop?
I am currently using matlab R2019b version.
Thank you!
  4 Kommentare
James Tursa
James Tursa am 26 Feb. 2020
So R is 1x3 and changing each iteration?
Paul
Paul am 26 Feb. 2020
yes
G = [...; ...; ...]
for a=0 to 5
for b = 0 to 5
for c = 0 to 5
R= [a b c];
R*G*R.'
end
end
end

Melden Sie sich an, um zu kommentieren.

Antworten (1)

KALYAN ACHARJYA
KALYAN ACHARJYA am 27 Feb. 2020
Bearbeitet: KALYAN ACHARJYA am 27 Feb. 2020
Is it simmilar?
G=[-0.00101584090085100 -0.0373729264800720 0.00786581385357300
-0.0373729264800720 -0.284509289498308 0.0752540345065320
0.00786581385357300 0.0752540345065320 -0.0158385837800100];
tic
result=cell(1,26800);
for i=1:26800
R=randi(10,[1,3]); % or Call the R here
result{i}=R*G*R';
end
toc
#
Elapsed time is 0.194492 seconds. (Measuring Elapsed Time Using tic and toc)

Community Treasure Hunt

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

Start Hunting!

Translated by