slow access to objects within 'cell' variables
Jaroslav Hajek
highegg at gmail.com
Thu Jan 8 15:16:06 CST 2009
On Thu, Jan 8, 2009 at 4:50 PM, Łukasz Sowiński <lukasz.sowinski at post.pl> wrote:
> Bug report for Octave 3.0.3 configured for i686-pc-linux-gnu
>
> Description:
> -----------
>
> * Access to objects within cell type depends on their size and can be
> really slow.
> F.i. if
> a{1} = zeros(1, 10);
> b{1} = zeros(1, 10000000);
> then
> a{1}(1) = 1;
> is much faster than
> b{1}(1) = 1;
> .
>
> Repeat-By:
> ---------
>
> * Please execute the following code:
>
> n_write = 1000;
> for n_alloc = n_write*[1 10 100 1000]
> y{1} = zeros(1, n_alloc);
> timer = -cputime;
> for i=1:n_write
> y{1}(:, i) = 1;
> endfor
> disp(timer + cputime);
> endfor
>
>
>
I've uploaded the following patch, which seems to fix this problem:
http://hg.savannah.gnu.org/hgweb/octave/rev/7b25349b32e6
Also, doing
a{1} = zeros(1,10);
a{1:2}(1) = 1
will now give an error as in Matlab.
thanks for this report,
--
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz
More information about the Bug-octave
mailing list