octave-maintainers
[Top][All Lists]
Advanced

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

Speed of for-loops


From: John W. Eaton
Subject: Speed of for-loops
Date: Mon, 30 Apr 2007 13:13:02 -0400

On 30-Apr-2007, David Bateman wrote:

| I took a look at the code n pt-loop.cc to see if there was some way to
| get a speed improvement from the for-loops. I found a few possible
| improvements and one error. Firstly for the error, in DO_ND_LOOP the
| values j and nr are of type int, when they should be of type
| octave_idx_type, otherwise 64-bit indexing over matrices won't work
| correctly.
| 
| The speed-up make the most impact when the argument to the for-loop is a
| matrix, though I did speed up Cell and Range types as well a little. The
| speed-ups include
| 
| 1) predefining several variables
| 2) Removing redundant assignments of the variable "quit" as it is always
| defined in quit_loop_now.
| 3) Special case rows = 0 and 1 cases in loops over arrays.
| 4) Include some of the code that was separate from the macro DO_ND_LOOP
| in the macro itself

I checked in this patch.

Thanks,

jwe


reply via email to

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