[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: data structure for simulation
From: |
Francesco Potorti` |
Subject: |
Re: data structure for simulation |
Date: |
Tue, 17 Mar 2009 16:10:53 +0100 |
>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: address@hidden
(entrance 20, 1st floor, room C71) Web: http://fly.isti.cnr.it/
- data structure for simulation, Francesco Potorti`, 2009/03/17
- Re: data structure for simulation, Francesco Potorti`, 2009/03/18
- Re: data structure for simulation, Michael Creel, 2009/03/18
- Re: data structure for simulation, Francesco Potorti`, 2009/03/18
- Re: data structure for simulation, Michael Creel, 2009/03/18
- Re: data structure for simulation, Francesco Potorti`, 2009/03/19
- Re: data structure for simulation, Michael Creel, 2009/03/20
- Re: data structure for simulation, Jaroslav Hajek, 2009/03/18