From bug-request at octave dot org Fri Jan 13 23:59:25 2006 Subject: Re: [OctDev] Proposed changes to cell2mat and inclusion in Octave From: Paul Kienzle To: Laurent Mazet Cc: "'bug at octave dot org' mailing list" , Octave Forge Date: Sat, 14 Jan 2006 00:57:57 -0500 --Apple-Mail-6--2712428 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed Laurent, I applied your fix to octave-forge. Someone with a working 2.9.x will have to check if the fix is needed there as well. Here's the test: assert (cell2mat({1, 2, 3}), [1, 2, 3]); assert (cell2mat({1; 2; 3}), [1; 2; 3]); See attached for Laurent's fix as a patch to the current octave CVS. * general/cell2mat.m: support 1D cell argument. - Paul On Jan 13, 2006, at 12:16 PM, Laurent Mazet wrote: > On Thu, 8 Dec 2005 21:31:56 +0800 > William Poetra Yoga Hadisoeseno wrote: > ... > > Hi, > > Sorry I'm late to comment the post. > > First, I found a bug on 1D cell argument (file attached). I will > update the > octave-forge version as soon I managed to boot again my own coputer (HD > controler broken :-( ) > > Seconldy, I read the code you added for dimension and type checking > but I don't > think it's efficient for a such function. This type of function has to > been run > as fast as possible and usualy no-ones care of the error message > (except > during the debugging process). From my point of view, cell2mat don't > have to > waste time on input checking. > > Laurent > -- > Dr. Laurent Mazet: Research Engineer /V\ Centre de Recherche de > MOTOROLA > Tel: +33 1 69 35 48 30 =-=-=-=-=-=-=-= Email: > laurent dot mazet at motorola dot com > --Apple-Mail-6--2712428 Content-Transfer-Encoding: 7bit Content-Type: application/octet-stream; x-unix-mode=0644; name="cell2mat.patch" Content-Disposition: attachment; filename=cell2mat.patch Index: cell2mat.m =================================================================== RCS file: /cvs/octave/scripts/general/cell2mat.m,v retrieving revision 1.1 diff -c -p -r1.1 cell2mat.m *** cell2mat.m 14 Dec 2005 18:21:55 -0000 1.1 --- cell2mat.m 14 Jan 2006 05:53:32 -0000 *************** function m = cell2mat (c) *** 54,64 **** sz(end) = 1; c1 = cell (sz); for i = 1:(prod (sz)) ! c1{i} = cat (k, c{i:(prod (sz)):end}); endfor c = c1; endfor ! m = cat (1, c1{:}); endif endfunction --- 54,64 ---- sz(end) = 1; c1 = cell (sz); for i = 1:(prod (sz)) ! c1{i} = cat (k, c{i:(prod (sz)):end}, []); endfor c = c1; endfor ! m = cat (1, c1{:}, []); endif endfunction *************** endfunction *** 70,75 **** --- 70,77 ---- %! E = [1 2 3 4; 5 6 7 8; 9 10 11 12]; %! F = E; F(:,:,2) = E; %!assert (cell2mat (C), E); + %!assert (cell2mat({1, 2, 3}), [1, 2, 3]); + %!assert (cell2mat({1; 2; 3}), [1; 2; 3]); %!test %! if ([1e6,1e4,1] * str2num (split (version, '.')) > 2010064) %! assert (cell2mat (D), F); % crashes octave 2.1.64 --Apple-Mail-6--2712428-- ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------