data structure for simulation
Francesco Potorti`
Potorti at isti.cnr.it
Tue Mar 17 10:10:53 CDT 2009
>What's wrong?
Efficiency :)
This is an issue with cell arrays, in fact. I realise that my question
can be reformulated more simply like this:
octave> a=cell(1e6,1);
octave> a(1e6)=1;
octave> whos a
Variables in the current scope:
Attr Name Size Bytes Class
==== ==== ==== ===== =====
a 1000000x1 8 cell
Total is 1000000 elements using 8 bytes
So Octave internally knows that only an element in the cell array is
nonempty and does not allocate memory for the whole array. But if I
want to know the index of the nonempty cell, doing
find (! cellfun (@isempty, a))
needs a non-negligible computing time, because cellfun goes through all
elements, be they empty or not. I hoped there was an efficient way of
knowing indexes of nonempty elements.
--
Francesco Potortì (ricercatore) Voice: +39 050 315 3058 (op.2111)
ISTI - Area della ricerca CNR Fax: +39 050 315 2040
via G. Moruzzi 1, I-56124 Pisa Email: Potorti at isti.cnr.it
(entrance 20, 1st floor, room C71) Web: http://fly.isti.cnr.it/
More information about the Help-octave
mailing list