From bug-request at octave dot org Thu Nov 24 19:20:43 2005 Subject: Re: isequal From: William Poetra Yoga H To: bug at octave dot org Date: Thu, 24 Nov 2005 17:19:29 -0800 (PST) Sorry, I wasn't quite specific about the functions isequal and isequalwithequalnans, and I made the mistake of sending a file instead of a patch. OK, here is the description: 1. isequal checks for equality for a number of objects. It does this recursively for objects of class "struct" and "cell" in Matlab. For Octave, we have the "list" class, which is treated similarly to "cell". I don't know whether Matlab checks for equality between strings, but I think that would be useful. 2. isequalwithequalnans is identical to isequal except that it assumes NaN == NaN. This is useful for comparing numeric arrays. The current isequal.m file in the Octave distribution is well written, but it can be easily extended to allow us to implement isequalwithequalnans. So what I did was: 1. Extend isequal.m's functionality a bit, to enable NaN == NaN checking. I did this by adding an option _nan to it. 2. Modify the looping method. 3. Rename isequal.m to _isequal.m 4. Write isequal.m and isequalwithequalnans.m which call _isequal with different options. Here's how it's implemented in the new isequal.m: tf = _isequal (0, x, varargin{:}); And for isequalwithequalnans.m tf = _isequal (1, x, varargin{:}); The help message for _isequal.m is essentially: _isequal (_NAN, X1, X2, ...) Return true if X1, X2, ... are all equal and _NAN evaluates to false. If _NAN evaluates to true, then assume NaN == NaN. I think this function is useful for compatibility with Matlab. I was wrong to attach the function files last time, but now I know how to make a diff for new files (like what I did for blkdiag.m) and add a changelog entry ;) What does John think about this? William Poetra Yoga Hadisoeseno __________________________________ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com ------------------------------------------------------------- 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 -------------------------------------------------------------