From bug-octave-request at bevo dot che dot wisc dot edu Tue Dec 16 18:37:02 2003 Subject: [] & [] fails From: "John W. Eaton" To: Paul Kienzle Cc: bug-octave at bevo dot che dot wisc dot edu Date: Tue, 16 Dec 2003 18:36:46 -0600 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 also added sub2ind and ind2sub functions that are N-d aware. I 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. jwe ------------------------------------------------------------- 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 -------------------------------------------------------------