help-octave
[Top][All Lists]
Advanced

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

trying to optimize my octave program


From: Tim Rueth
Subject: trying to optimize my octave program
Date: Wed, 17 Mar 2010 11:41:30 -0700

I have just finished writing my first octave program.  It works beautifully (I love Octave!), but there's just one problem:  The program runs for days (literally).  Of course, this is because it is processing lots of data, and running a number of for-loops.  I tried to minimize the number of loops, but the remaining ones are unavoidable as far as I can tell, even with Octave's powerful built-in matrix functions.  I also made sure I didn't create any large matrices or vectors inside these loops and have declared most of my matrices global.  The main script has 7 nested for-loops and in the inner-most loop I call a custom function that has yet another for-loop, which iterates over 4000 times.  Ouch.  After doing extensive testing using tic and toc, I found no single instruction or set of instructions within a loop that take any appreciable time...in other words, the code runs fast, but there's just lots of data to process.
 
Okay, so it's no surprise that it runs for days, but my question is:  Is there anything else I can do to speed it up, short of buying a faster computer?  I read the appendix in the Octave manual that talks about making oct files, but do you think compiling the custom function in the inner-most for-loop that then has its own 4000-iteration for-loop will help at all?  Each iteration in this inner-most loop currently takes much less than 0.01 sec, so I question whether compiling the function that contains this loop will help much.  I could just try it and see, but I'm a complete newbie here (I've never written a C program), and don't want to invest the time if it isn't going to help much.  Any advice here would be greatly appreciated.  Thanks.

reply via email to

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