From: Paul K. <pki...@ki...> - 2001-05-18 08:38:57
|
I collected some patches in matcompat. I don't know if it was worth the trouble though. I suppose it wouldn't hurt to create a new top level directory /patches, just so long as nothing in main depends upon them. - Paul On Tue, May 16, 2000 at 10:46:23PM -0400, Julian A. de Marchi, Ph.D wrote: > I've been watching patches & usage tips float past it seems forever now. > Do y'all not fancy we could compile these @SF in a way that's easier to > use than troving through the octave.org mailing list archives? > > Another unsolicited, obvious, back-seat remark from > joolean > > > -----Original Message----- > From: oct...@be... > [mailto:oct...@be...]On Behalf Of Jianming > Sent: Thursday, May 17, 2001 6:47 AM > To: Paul Kienzle; octave-sources > Cc: John W. Eaton > Subject: Re: Cell array support > > > Hi, > Attached are the new patches for cell array support with octave > (2.1.34). After experimenting with various implementations, I've taken most > of your advices regarding the following: > 1. Using () to access cell elements should not narrow down to the base > type automatically. This will reduce confusion. I.E, narrowing conversion is > removed. > 2. Using ASSIGNANYOP in op-cell.cc > > Attached also is a sample session with the patch. Some comments on the > (incomplete) patch: > > 1. Some features with Paul mentioned in the previous email are missing: > a) {} producing multi-valued output > b) {} receive multi-valued output, > c) splice cell arrays into an argument list à la Matlab: > 2. As shown in the sample session, assigning cell elements to an > undefined indexed variable will give an error. To overcome this, cell(0,0) > must be used first to "declare" the variable as a cell. There is no problem > assigning cell elements to an undefined variable in it's entirety though. > 3. Increasing the size of a cell array will not give unassigned elements > as empty matrices as Matlab does. Instead, the undefined elements will have > undefined type until assigned a value. > 4. Removing elements from a cell is done using {} instead of []. This is > simpler to implement. In fact, there is no need for any code for this. If we > want to use [], I believe we have to delibrately check the type of the left > hand side first. I don't really like this hack. > > Any comments, improvements are welcomed. Thanks Paul for your comments > in the previous emails. I hope this gets into 2.1.35 together with some of > your patches for cell functions. > > Regards, > Jianming > octave:1> A(1,1) = {[1 4 3; 0 5 8; 7 2 9]}; > error: operator =: no conversion for assignment of `cell' to indexed `<unknown type>' > error: evaluating assignment expression near line 1, column 8 > octave:1> A{1,1} = [1 4 3; 0 5 8; 7 2 9]; > error: A(I, J) = X: X must be a scalar or the number of elements in I must > error: match the number of rows in X and the number of elements in J must > error: match the number of columns in X > error: evaluating assignment expression near line 1, column 8 > octave:1> A=cell(0,0); > octave:2> A(1,1) = {[1 4 3; 0 5 8; 7 2 9]}; > octave:3> A{1,2} = 'Anne Smith' > A = > > {[1,1] = > > 1 4 3 > 0 5 8 > 7 2 9 > > [1,2] = Anne Smith > } > > octave:4> A{2,2} = -pi:pi/10:pi > A = > > {[1,1] = > > 1 4 3 > 0 5 8 > 7 2 9 > > [2,1] = > > error: octave_base_value::print (): wrong type argument `<unknown type>' > > [1,2] = Anne Smith > [2,2] = > > Columns 1 through 8: > > -3.1416 -2.8274 -2.5133 -2.1991 -1.8850 -1.5708 -1.2566 -0.9425 > > > Columns 9 through 16: > > -0.6283 -0.3142 0.0000 0.3142 0.6283 0.9425 1.2566 1.5708 > > > Columns 17 through 21: > > 1.8850 2.1991 2.5133 2.8274 3.1416 > > } > > octave:5> C = {[1 2], [3 4]; [5 6], [7 8]} > C = > > {[1,1] = > > 1 2 > > [2,1] = > > 5 6 > > [1,2] = > > 3 4 > > [2,2] = > > 7 8 > > } > > octave:6> C=A{1,1} > C = > > 1 4 3 > 0 5 8 > 7 2 9 > > octave:7> d=A{1,1}(2,2) > d = 5 > > octave:8> A(1,:) > ans = > > {[1,1] = > > 1 4 3 > 0 5 8 > 7 2 9 > > [1,2] = Anne Smith > } > > octave:9> A(2,:)=[] > A = > > {[1,1] = > > 1 4 3 > 0 5 8 > 7 2 9 > > [2,1] = [](0x0) > [1,2] = Anne Smith > [2,2] = [](0x0) > } > > octave:10> A(2,:)={} > A = > > {[1,1] = > > 1 4 3 > 0 5 8 > 7 2 9 > > [1,2] = Anne Smith > } |