octave-maintainers
[Top][All Lists]
Advanced

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

Attn: Patch Re: iterating cell arrays


From: David Bateman
Subject: Attn: Patch Re: iterating cell arrays
Date: Fri, 25 Jun 2004 02:38:57 +0200
User-agent: Mutt/1.4.1i

Ok, so if x is an NDArray or ND Cell array, Matlab iterates 
prod(size(a)(2:end)), passing column vectors of length size(a,1). 
This doesn't make any sense to me, since why is the first dimension
privileged in this manner. To be consistent with the use of
NDArrays elsewhere, the for loop should accept a "dim" argument that
specifies the dimension over which the array is iterated. But that
is likely to be very ugly. 

Frankly, I think the behaviour should be to loop over all of the
elements rather than the columns. However this is probably a case
where compatibility (with pass behaviour of octave on matrices, and
matlab on NDArrays and cell arrays) makes more sense. In that case
here is a patch that makes cell and NDArrays behave the same way as in
Matlab when used in a for loop.

Note that I had the delete the constructor octave_value(ArrayN<Complex>)
in ov.h as it wasn't defined. Also note that the contructor of idx_vector
uses the same indexing as in octave but stores the index internally
in c++ style. Thus the "+2" in the patch is effectively a "+1", and
increments the index as expected.

Regards
David



-- 
David Bateman                                address@hidden
Motorola CRM                                 +33 1 69 35 48 04 (Ph) 
Parc Les Algorithmes, Commune de St Aubin    +33 1 69 35 77 01 (Fax) 
91193 Gif-Sur-Yvette FRANCE

The information contained in this communication has been classified as: 

[x] General Business Information 
[ ] Motorola Internal Use Only 
[ ] Motorola Confidential Proprietary

Attachment: patch.forloop
Description: Text document


reply via email to

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