0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030 function result = generic_eq(obj1, obj2, varargin, DEFAULT_PLIST, VERSION, CATEGORY)
0031
0032
0033 if isobject(obj1) && ischar(obj2)
0034 in = char(obj2);
0035 if strcmp(in, 'Params')
0036 result = DEFAULT_PLIST;
0037 return
0038 elseif strcmp(in, 'Version')
0039 result = VERSION;
0040 return
0041 elseif strcmp(in, 'Category')
0042 result = CATEGORY;
0043 return
0044 end
0045 end
0046
0047
0048 if ~strcmp(class(obj1), class(obj2))
0049 disp(sprintf('\nNOT EQUAL: The objects are not from the same class. [%s] <-> [%s]', class(obj1), class(obj2)));
0050 result = 0;
0051 return
0052 end
0053
0054
0055 if numel(obj1) ~= numel(obj2)
0056 disp(sprintf('\nNOT EQUAL: The size of the %s-object''s. [%d] <-> [%d]', class(obj1), numel(obj1), numel(obj2)));
0057 result = 0;
0058 return
0059 end
0060
0061 exception_list = varargin;
0062
0063
0064 if ~isempty(exception_list) && isa(exception_list{1}, 'plist')
0065 exception_list = find(exception_list{1}, 'Exceptions');
0066 if isempty(exception_list)
0067 exception_list = cell(0);
0068 elseif ~iscell(exception_list)
0069 exception_list = cellstr(exception_list);
0070 end
0071 end
0072
0073
0074 for jj = 1:numel(obj1)
0075
0076 result = 1;
0077
0078 fields = fieldnames(obj1(jj));
0079
0080 for ii = 1:length(fields)
0081 field = fields{ii};
0082
0083
0084
0085 ck_field = {field, sprintf('%s/%s', class(obj1), field)};
0086
0087
0088
0089
0090 if ismember(field, {'hist', 'inhists'})
0091 ck_field{end+1} = 'history';
0092 ck_field{end+1} = sprintf('%s/history', class(obj1));
0093 elseif strcmp(field, 'val')
0094 ck_field{end+1} = 'value';
0095 ck_field{end+1} = sprintf('%s/value', class(obj1));
0096 end
0097
0098
0099 if ~(any(ismember(ck_field, exception_list)))
0100
0101
0102 if isobject(obj1(jj).(field))
0103
0104
0105 if length(obj1(jj).(field)) ~= length(obj2(jj).(field))
0106 disp(sprintf('\nNOT EQUAL: The property [%s] of the object [%s] have not the same size', field, class(obj1)));
0107 result = 0;
0108 return
0109 end
0110
0111
0112 for kk = 1:numel(obj1(jj).(field))
0113 if ~eq(obj1(jj).(field)(kk), obj2(jj).(field)(kk), exception_list{:})
0114 result = 0;
0115 if numel(obj1(jj).(field)) > 1
0116 disp(sprintf('\nNOT EQUAL: %s.%s (%d. element)', class(obj1(jj)), field, kk));
0117 else
0118 disp(sprintf('\nNOT EQUAL: %s.%s', class(obj1(jj)), field));
0119 end
0120 return
0121 end
0122 end
0123 else
0124 if ~isequalwithequalnans(obj1(jj).(field), obj2(jj).(field))
0125 result = 0;
0126 if numel(obj1(jj)) > 1
0127 disp(sprintf('\nNOT EQUAL: %s.%s (%d. object)', class(obj1(jj)), field, jj));
0128 else
0129 disp(sprintf('\nNOT EQUAL: %s.%s', class(obj1(jj)), field));
0130 end
0131 return
0132 end
0133 end
0134
0135 end
0136 end
0137
0138 end
0139