Home > classes > @pole > eq.m

eq

PURPOSE ^

EQ overloads the == operator for pole objects.

SYNOPSIS ^

function result = eq(c1,c2, varargin)

DESCRIPTION ^

 EQ overloads the == operator for pole objects.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: EQ overloads the == operator for pole objects.

              All fields are checked.

 CALL:        result = eq(c1,c2)
              result = eq(c1,c2,  exc_list)
              result = eq(c1,c2, 'property1', 'property2')
              result = eq(c1,c2, 'class/property', 'class/property')

 EXAMPLES:    result = eq(c1,c2, 'name', 'created')
              result = eq(c1,c2, 'ao/name')

 INPUTS:      c1,c2    - input pole objects
              exc_list - exception list
                         List of properties which are not checked.

 OUTPUTS:     If the two pole objects are considered equal, result == 1,
              otherwise, result == 0.

 VERSION:     $Id: eq.m,v 1.3 2008/01/02 17:58:51 ingo Exp $

 HISTORY:     29-08-2007 M Hewitson
                 Creation

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function result = eq(c1,c2, varargin)
0002 % EQ overloads the == operator for pole objects.
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: EQ overloads the == operator for pole objects.
0007 %
0008 %              All fields are checked.
0009 %
0010 % CALL:        result = eq(c1,c2)
0011 %              result = eq(c1,c2,  exc_list)
0012 %              result = eq(c1,c2, 'property1', 'property2')
0013 %              result = eq(c1,c2, 'class/property', 'class/property')
0014 %
0015 % EXAMPLES:    result = eq(c1,c2, 'name', 'created')
0016 %              result = eq(c1,c2, 'ao/name')
0017 %
0018 % INPUTS:      c1,c2    - input pole objects
0019 %              exc_list - exception list
0020 %                         List of properties which are not checked.
0021 %
0022 % OUTPUTS:     If the two pole objects are considered equal, result == 1,
0023 %              otherwise, result == 0.
0024 %
0025 % VERSION:     $Id: eq.m,v 1.3 2008/01/02 17:58:51 ingo Exp $
0026 %
0027 % HISTORY:     29-08-2007 M Hewitson
0028 %                 Creation
0029 %
0030 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0031 
0032 VERSION  = '$Id: eq.m,v 1.3 2008/01/02 17:58:51 ingo Exp $';
0033 
0034 % Check if this is a call for parameters
0035 if nargin == 2
0036   if isa(c1, 'pole') && ischar(c2)
0037     in = char(c2);
0038     if strcmp(in, 'Params')
0039       result = plist;
0040       return
0041     elseif strcmp(in, 'Version')
0042       result = VERSION;
0043       return
0044     end
0045   end
0046 end
0047 
0048 result = 1;
0049 
0050 %% Check class
0051 if ~strcmp(class(c1), class(c2))
0052   result = 0;
0053   return
0054 end
0055 
0056 fields = fieldnames(c1);
0057 
0058 for ii = 1:length(fields)
0059   field   = fields{ii};
0060 
0061   ck_field = {field, ['pole/' field]};
0062 
0063   %% Check tag
0064   if ~(any(ismember(ck_field, varargin)))
0065 
0066     if isobject(c1.(field))
0067 
0068       if length(c1.(field)) ~= length(c2.(field))
0069         result = 0;
0070         return
0071       end
0072 
0073       for jj = 1:length(c1.(field))
0074         if ~eq(c1.(field)(jj), c2.(field)(jj), varargin{:})
0075           result = 0;
0076           disp(sprintf('\nNOT EQUAL: %s.%s', class(c1), field));
0077           return
0078         end
0079       end
0080     else
0081       if ~isequalwithequalnans(c1.(field), c2.(field))
0082         result = 0;
0083         disp(sprintf('\nNOT EQUAL: %s.%s', class(c1), field));
0084         return
0085       end
0086     end
0087 
0088   end
0089 end
0090

Generated on Tue 22-Jan-2008 10:39:13 by m2html © 2003