octave-maintainers
[Top][All Lists]
Advanced

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

3D versus 2D Indexing and the Speed Thereof


From: Luis Ortiz
Subject: 3D versus 2D Indexing and the Speed Thereof
Date: Mon, 20 Nov 2006 19:10:00 -0500

Folks:

One of my engineers reported an odd performance problem in Octave, 
which I am afraid to tackle without a little bit of guidance.
The first snippet of code he gave me to consider was:
         x=zeros(100,50,100);
         tic;
         for i = 1:100
             z = x(:,:,i);
         end
         toc

The second snippet of code he gave me to consider was:
         x=zeros(5000,100);
         tic;
         for i = 1:100
             z = x(:,i);
         end
         toc

Now the 2D form is about 22 times faster than the 3D form, even though
the amount of data being slung about is the same.

It would seem to me that indexing operations involving :'s on all
dimensions except the last, where the index is a scalar, ought
to be particularly fast and easy.   Could any of you point me where
to look to fix this or tell what where I ought to add code
to support a faster way of doing this?

I started by profiling a statically linked octave to see where it was
spending its time, and decided that it might be wiser for me
to ask first before diving deep and drowning.

--Luis



reply via email to

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