Mercurial > hg > octave-nkf
diff scripts/general/isequal.m @ 5549:6db3a5df1eab
[project @ 2005-11-30 03:15:19 by jwe]
author | jwe |
---|---|
date | Wed, 30 Nov 2005 03:15:24 +0000 |
parents | c8783205a7c6 |
children | 815926a781f6 |
line wrap: on
line diff
--- a/scripts/general/isequal.m +++ b/scripts/general/isequal.m @@ -1,81 +1,35 @@ -## Copyright (C) 2000 Paul Kienzle +## Copyright (C) 2005 William Poetra Yoga Hadisoeseno ## ## This file is part of Octave. ## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2, or (at your option) -## any later version. +## Octave is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. ## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. +## Octave is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, write to the Free -## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -## 02110-1301, USA. +## along with Octave; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ## -*- texinfo -*- -## @deftypefn {Function File} {} isequal (@var{x1}, @var{x2}, @dots{}, @var{xN}) -## Return true if all parts of @var{x1}, @var{x2}, @dots{}, @var{xN} are -## equal. +## @deftypefn {Function File} {} isequal (@var{x1}, @var{x2}, ...) +## Return true if all of @var{x1}, @var{x2}, ... are equal. ## @end deftypefn +## +## @seealso{isequalwithequalnans} -## Author: Paul Kienzle -## Adapted-by: jwe - -function t = isequal (x, varargin) +function tf = isequal (x, varargin) if (nargin < 2) - usage ("isequal (x, y, ...)"); - endif + usage ("isequal (x1, x2, ...)"); + end - for arg = 1:length (varargin) - y = varargin{arg}; - if (isstruct (x)) - t = isstruct (y); - for [v, k] = x - t = (t - && struct_contains (y, k) - && isequal (getfield (x, k), getfield (y, k))); - endfor - for [v, k] = y - t = t && struct_contains (x, k); - endfor - elseif (islist (x)) - t = islist(y) && length(x) == length(y); - if (! t) - return; - endif - for i = 1:length (x) - t = isequal (x{i}, y{i}); - if (! t) - return; - endif - endfor - elseif (any (size (x) != size (y))) - t = false; - elseif (iscell (x) || islist (x)) - t = iscell (y) || islist (y); - if (! t) - return; - endif - x = x(:); - y = y(:); - for i = 1:length (x) - t = isequal (x{i}, y{i}); - if (! t) - return; - endif - endfor - else - t = all (x(:) == y(:)); - endif - if (! t) - return; - endif - endfor + tf = __isequal__ (0, x, varargin{:}); endfunction +