help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Speed Optimization on Fix Matrix Looping


From: lain.ux
Subject: Speed Optimization on Fix Matrix Looping
Date: Sun, 04 May 2008 18:31:38 +0000
User-agent: Icedove 1.5.0.14pre (X11/20080305)

Hi,

I have tried to run my octave code with following two test cases and gotten the elapsed time. As the result, test case 2 is executed much faster than case 1.

Case 1:
b = [];
for i = 1:N
       b(i, 1:P) = i * ones (1, P);
endfor

Case 2:
b = 1.0 * ones (N, P);  # this line doesn't effect the final matrix b
                       # value. but with this line, the execution time
                       # becomes much-much faster
for i = 1:N
       b(i, 1:P) = i * ones (1, P);
endfor

My platform:
- Processor: Intel Core 2 Duo
- Operating System: Debian GNU/Linux 4
- Octave Version: 3.0.1

My questions are:
1) Is the test result correct?
2) Has anyone test about it?

Suggestion:
I see that b = []; is mostly used on Octave codes. If the result is correct (can improve the speed), I think, it better to be changed automatically during the parsing step so needless for user to change the line manually.

Please find the complete test code and result from my blog:
http://l411v.blogspot.com/2008/04/octave-speed-optimization-080426.html

Thanks,
lain.ux


reply via email to

[Prev in Thread] Current Thread [Next in Thread]