From bug-octave-request at bevo dot che dot wisc dot edu Tue Dec 16 21:13:12 2003 Subject: Re: [] & [] fails From: Paul Kienzle To: bug-octave at bevo dot che dot wisc dot edu Date: Tue, 16 Dec 2003 22:12:52 -0500 On Dec 16, 2003, at 7:36 PM, John W. Eaton wrote: > On 16-Dec-2003, John W. Eaton wrote: > > | The following patch should fix the crash. The find function still > | needs to be made N-d aware. > > I fixed the find function in CVS so that it can handle N-d arrays. I imagine there are a number of octave-forge routines that should be made dim aware as well. > I also added sub2ind and ind2sub functions that are N-d aware. I I can't see them on CVS. > based parts of them on the octave-forge code, but decided not to > handle matrix args or return values specially because it leads to > incompatibilities with Matlab. For example, Matlab allows all of > these: > > ind2sub ([3,4,5], [2,3,4,5]) > [i,j] = ind2sub ([3,4,5], [2,3,4,5]) > [i,j,k] = ind2sub ([3,4,5], [2,3,4,5]) > [i,j,k,l] = ind2sub ([3,4,5], [2,3,4,5]) > > In the first case, ind2sub behaves as if the dimensions are [60,1]. > In the second, it behaves as as if the dimensions are [3,20]. In the > fourth, it returns a vector of ones for the last index. The > current octave-forge code gives an error for the second and fourth > cases and returns i, j, and k indices in a matrix for the first case. Okay. I can't remove the functions from octave-forge since other octave-forge routines depend on them, so I may include yours instead, or better yet, have a facility to install them only if they are not already present. - Paul ------------------------------------------------------------- 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 -------------------------------------------------------------