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
0031
0032
0033
0034
0035
0036 function result = eq(obj1, obj2, varargin)
0037
0038
0039 hh = {obj1, obj2, varargin{:}};
0040 if utils.helper.isinfocall(hh{:})
0041 result = getInfo(varargin{1});
0042 return
0043 end
0044
0045 import utils.const.*
0046
0047
0048 if ~strcmp(class(obj1), class(obj2))
0049 utils.helper.msg(msg.PROC1, 'NOT 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 utils.helper.msg(msg.PROC1, 'NOT 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 if isa(obj1(jj).(field), 'sym')
0102
0103 if ~eq(obj1(jj).(field), obj2(jj).(field))
0104 result = 0;
0105 if numel(obj1(jj)) > 1
0106 utils.helper.msg(msg.PROC1, 'NOT EQUAL: %s.%s (%d. object)', class(obj1(jj)), field, jj);
0107 else
0108 utils.helper.msg(msg.PROC1, 'NOT EQUAL: %s.%s', class(obj1(jj)), field);
0109 end
0110 return
0111 end
0112
0113 elseif isobject(obj1(jj).(field))
0114
0115
0116
0117 if length(obj1(jj).(field)) ~= length(obj2(jj).(field))
0118 utils.helper.msg(msg.PROC1, 'NOT EQUAL: The property [%s] of the object [%s] have not the same size', field, class(obj1));
0119 result = 0;
0120 return
0121 end
0122
0123
0124 for kk = 1:numel(obj1(jj).(field))
0125 if ~eq(obj1(jj).(field)(kk), obj2(jj).(field)(kk), exception_list{:})
0126 result = 0;
0127 if numel(obj1(jj).(field)) > 1
0128 utils.helper.msg(msg.PROC1, 'NOT EQUAL: %s.%s (%d. element)', class(obj1(jj)), field, kk);
0129 else
0130 utils.helper.msg(msg.PROC1, 'NOT EQUAL: %s.%s', class(obj1(jj)), field);
0131 end
0132 return
0133 end
0134 end
0135
0136 else
0137
0138 if ~isequalwithequalnans(obj1(jj).(field), obj2(jj).(field))
0139 result = 0;
0140 if numel(obj1(jj)) > 1
0141 utils.helper.msg(msg.PROC1, 'NOT EQUAL: %s.%s (%d. object)', class(obj1(jj)), field, jj);
0142 else
0143 utils.helper.msg(msg.PROC1, 'NOT EQUAL: %s.%s', class(obj1(jj)), field);
0144 end
0145 return
0146 end
0147 end
0148
0149 end
0150 end
0151
0152 end
0153 end
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170 function ii = getInfo(varargin)
0171 if nargin == 1 && strcmpi(varargin{1}, 'None')
0172 sets = {};
0173 pl = [];
0174 else
0175 sets = {'Default'};
0176 pl = getDefaultPlist;
0177 end
0178
0179 ii = minfo(mfilename, 'ltpda_obj', '', utils.const.categories.relop, '$Id: eq.m,v 1.8 2008/09/04 15:29:30 ingo Exp $', sets, pl);
0180 end
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193 function plo = getDefaultPlist()
0194 plo = plist();
0195 end
0196