0
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 1 % EQ overloads the == operator for ltpda plist objects.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 3 %
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 4 % DESCRIPTION: EQ overloads the == operator for ltpda plist objects.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 5 %
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 6 % Two plists are considered equal if each has the same name,
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 7 % created time, version, creator and parameter objects. The
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 8 % order of the param-objects doesn't matter.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 9 %
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 10 % CALL: result = eq(u1,u2)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 11 %
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 12 % With a PLIST
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 13 %
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 14 % r = eq(obj1, obj2, plist('Exceptions', {'prop1', 'prop2'}))
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 15 % r = eq(obj1, obj2, plist('Tol', eps(1)))
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 16 % r = eq(obj1, obj2, plist('Exceptions', 'prop', 'Tol', 1e-14))
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 17 %
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 18 % INPUTS: pl1, pl2 - Input objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 19 %
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 20 % OUTPUTS: If the two objects are considered equal, result == true,
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 21 % otherwise, result == false.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 22 %
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 23 % <a href="matlab:utils.helper.displayMethodInfo('plist', 'eq')">Parameters Description</a>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 24 %
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 25 % VERSION: $Id: eq.m,v 1.27 2011/04/08 08:56:21 hewitson Exp $
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 26 %
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 27 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 28
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 29 function result = eq(obj1, obj2, varargin)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 30
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 31 % Check if this is a call for parameters
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 32 hh = [{obj1}, {obj2}, varargin];
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 33 if utils.helper.isinfocall(hh{:})
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 34 result = getInfo(varargin{1});
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 35 return
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 36 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 37
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 38 import utils.const.*
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 39
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 40 %%%%% Check class
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 41 if ~strcmp(class(obj1), class(obj2))
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 42 utils.helper.msg(msg.PROC1, 'NOT EQUAL: The objects are not from the same class. [%s] <-> [%s]', class(obj1), class(obj2));
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 43 result = false;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 44 return
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 45 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 46
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 47 %%%%% Check length of obj1 and obj2
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 48 if numel(obj1) ~= numel(obj2)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 49 utils.helper.msg(msg.PROC1, 'NOT EQUAL: The size of the %s-object''s. [%d] <-> [%d]', class(obj1), numel(obj1), numel(obj2));
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 50 result = false;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 51 return
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 52 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 53
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 54 plin = [];
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 55 exception_list = varargin;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 56 if ~isempty(varargin) && isa(varargin{1}, 'plist')
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 57 plin = varargin{1};
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 58 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 59
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 60 %%%%% Get the tolerance from a potential existing plist
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 61 if ~isempty(plin) && plin.isparam('tol')
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 62 tol = plin.find('tol');
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 63 else
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 64 dpl = getDefaultPlist();
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 65 tol = dpl.find('tol');
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 66 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 67
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 68 %%%%% Convert a potential existing plist into a exception
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 69 if ~isempty(plin) && plin.isparam('exceptions')
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 70 exception_list = find(plin, 'Exceptions');
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 71 if isempty(exception_list)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 72 exception_list = cell(0);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 73 elseif ~iscell(exception_list)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 74 exception_list = cellstr(exception_list);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 75 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 76 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 77
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 78 result = true;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 79
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 80 %%%%% for each element in obj1 and obj2
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 81 for jj = 1:numel(obj1)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 82
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 83 if isa(obj1, 'ltpda_uoh')
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 84 utils.helper.msg(msg.PROC1, 'testing %s against %s', obj1.name, obj2.name);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 85 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 86
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 87 fields = fieldnames(obj1(jj));
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 88
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 89 for ii = 1:length(fields)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 90 field = fields{ii};
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 91
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 92 %%%%% Creates the exception list for the current field.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 93 %%%%% For example: {'name', 'ao/name'}
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 94 ck_field = {field, sprintf('%s/%s', class(obj1), field)};
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 95
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 96 % Special case (for the ao- and history-class):
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 97 % Is the field = 'hist', 'inhists' then add 'history' to the exception list.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 98 %%%%% For example: {'history', 'ao/history'}
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 99 if utils.helper.ismember(field, {'hist', 'inhists'})
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 100 ck_field{end+1} = 'history';
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 101 ck_field{end+1} = sprintf('%s/history', class(obj1));
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 102 elseif strcmp(field, 'val')
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 103 ck_field{end+1} = 'value';
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 104 ck_field{end+1} = sprintf('%s/value', class(obj1));
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 105 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 106
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 107 %%%%% Check field if it is not in the exception list
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 108 if ~(any(utils.helper.ismember(ck_field, exception_list)))
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 109
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 110 if isa(obj1(jj).(field), 'sym')
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 111 %%%%%%%%%% The property is a sym-object %%%%%%%%%%
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 112 if ~eq(obj1(jj).(field), obj2(jj).(field))
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 113 result = false;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 114 disaply_msg(obj1, jj, field)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 115 return
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 116 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 117
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 118 elseif isa(obj1(jj).(field), 'ltpda_obj')
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 119 %%%%%%%%%% The property is a ltpda-object %%%%%%%%%%
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 120
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 121 %%%%% Check the length of the property
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 122 if length(obj1(jj).(field)) ~= length(obj2(jj).(field))
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 123 utils.helper.msg(msg.PROC1, 'NOT EQUAL: The property [%s] of the object [%s] have not the same size %d <-> %d.', field, class(obj1), length(obj1(jj).(field)), length(obj2(jj).(field)));
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 124 result = false;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 125 return
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 126 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 127
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 128 %%%%% Special case for param-objects because the order shouldn't matter
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 129 if isa(obj1(jj).(field), 'param')
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 130
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 131 if ~eqparam(obj1(jj).(field), obj2(jj).(field), exception_list, tol)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 132 result = false;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 133 disaply_msg(obj1, jj, field)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 134 return
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 135 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 136
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 137 else
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 138 %%%%% For each element of the property
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 139 for kk = 1:numel(obj1(jj).(field))
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 140 if isempty(plin)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 141 % Command with a list of exceptions
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 142 res = eq(obj1(jj).(field)(kk), obj2(jj).(field)(kk), exception_list{:});
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 143 else
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 144 % Command with a PLIST
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 145 res = eq(obj1(jj).(field)(kk), obj2(jj).(field)(kk), plin);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 146 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 147 if ~res
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 148 result = false;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 149 disaply_msg(obj1, jj, field)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 150 return
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 151 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 152 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 153 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 154
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 155 elseif isstruct(obj1(jj).(field))
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 156 %%%%%%%%%% The property is a structure %%%%%%%%%%
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 157
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 158 if ~eqstruct(obj1(jj).(field), obj2(jj).(field), exception_list, tol)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 159 result = false;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 160 disaply_msg(obj1, jj, field)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 161 return
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 162 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 163
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 164 elseif iscell(obj1(jj).(field))
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 165 %%%%%%%%%% The property is a cell array %%%%%%%%%%
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 166
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 167 if ~eqcell(obj1(jj).(field), obj2(jj).(field), exception_list, tol)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 168 result = false;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 169 disaply_msg(obj1, jj, field)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 170 return
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 171 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 172
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 173 elseif isnumeric(obj1(jj).(field))
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 174 %%%%%%%%%% The property is an elemental MATLAB datatype %%%%%%%%%%
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 175 if ~utils.math.isequal(obj1(jj).(field), obj2(jj).(field), tol)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 176 result = false;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 177 disaply_msg(obj1, jj, field)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 178 return
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 179 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 180 else
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 181 %%%%%%%%%% The property is an elemental MATLAB datatype %%%%%%%%%%
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 182 if ~isequal(obj1(jj).(field), obj2(jj).(field))
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 183 result = false;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 184 disaply_msg(obj1, jj, field)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 185 return
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 186 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 187 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 188
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 189 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 190 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 191
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 192 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 193 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 194
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 195
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 196 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 197 % Local Functions %
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 198 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 199
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 200 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 201 %
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 202 % FUNCTION: disaply_msg
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 203 %
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 204 % DESCRIPTION: Diesplay a message if the objects are not equal
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 205 %
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 206 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 207
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 208 function disaply_msg(obj, obj_no, field)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 209 import utils.const.*
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 210 if numel(obj) > 1
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 211 utils.helper.msg(msg.PROC1, 'NOT EQUAL: %s.%s (%d. object)', class(obj(obj_no)), field, obj_no);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 212 else
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 213 utils.helper.msg(msg.PROC1, 'NOT EQUAL: %s.%s', class(obj(obj_no)), field);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 214 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 215 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 216
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 217 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 218 %
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 219 % FUNCTION: eqstruct
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 220 %
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 221 % DESCRIPTION: Equal method to compare structures
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 222 %
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 223 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 224
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 225 function result = eqstruct(obj1, obj2, exception_list, tol)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 226
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 227 import utils.const.*
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 228
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 229 %%%%% Check class
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 230 if ~strcmp(class(obj1), class(obj2))
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 231 utils.helper.msg(msg.PROC1, 'NOT EQUAL: The objects are not from the same class. [%s] <-> [%s]', class(obj1), class(obj2));
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 232 result = false;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 233 return
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 234 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 235
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 236 %%%%% Check length of obj1 and obj2
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 237 fieldsA = fieldnames(obj1);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 238 fieldsB = fieldnames(obj2);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 239 if numel(fieldsA) ~= numel(fieldsB)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 240 utils.helper.msg(msg.PROC1, 'NOT EQUAL: The size of the %s-object''s. [%d] <-> [%d]', class(obj1), numel(obj1), numel(obj2));
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 241 result = false;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 242 return
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 243 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 244
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 245 result = true;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 246
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 247 for oo = 1:numel(obj1)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 248 for ii = 1:numel(fieldsA)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 249
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 250 if isa(obj1(oo).(fieldsA{ii}), 'ltpda_obj')
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 251 %%%%%%%%%%%%% LTPDA objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 252 if ~eq(obj1(oo).(fieldsA{ii}), obj2(oo).(fieldsA{ii}), plist('exceptions', exception_list, 'tol', tol))
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 253 result = false;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 254 disaply_msg(obj1, oo, fieldsA{ii})
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 255 return
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 256 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 257
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 258 elseif isstruct(obj1(oo).(fieldsA{ii}))
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 259 %%%%%%%%%%%%% STRUCTURE
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 260 if ~eqstruct(obj1(oo).(fieldsA{ii}), obj2(oo).(fieldsA{ii}), exception_list, tol)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 261 result = false;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 262 disaply_msg(obj1, oo, fieldsA{ii})
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 263 return
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 264 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 265
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 266 elseif iscell(obj1(oo).(fieldsA{ii}))
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 267 %%%%%%%%%%%%% STRUCTURE
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 268 if ~eqcell(obj1(oo).(fieldsA{ii}), obj2(oo).(fieldsA{ii}), exception_list, tol)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 269 result = false;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 270 disaply_msg(obj1, oo, fieldsA{ii})
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 271 return
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 272 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 273 elseif isnumeric(obj1(oo).(fieldsA{ii}))
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 274 if ~utils.math.isequal(obj1(oo).(fieldsA{ii}), obj2(oo).(fieldsA{ii}), tol)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 275 result = false;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 276 disaply_msg(obj1, oo, fieldsA{ii})
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 277 return
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 278 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 279
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 280 else
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 281 if ~isequal(obj1(oo).(fieldsA{ii}), obj2(oo).(fieldsA{ii}))
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 282 result = false;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 283 disaply_msg(obj1, oo, fieldsA{ii})
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 284 return
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 285 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 286 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 287
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 288 end % over all fields
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 289 end % over all objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 290
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 291 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 292
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 293 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 294 %
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 295 % FUNCTION: eqcell
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 296 %
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 297 % DESCRIPTION: Equal method to compare structures
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 298 %
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 299 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 300
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 301 function result = eqcell(obj1, obj2, exception_list, tol)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 302
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 303 import utils.const.*
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 304
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 305 %%%%% Check class
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 306 if ~strcmp(class(obj1), class(obj2))
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 307 utils.helper.msg(msg.PROC1, 'NOT EQUAL: The objects are not from the same class. [%s] <-> [%s]', class(obj1), class(obj2));
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 308 result = false;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 309 return
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 310 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 311
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 312 %%%%% Check length of obj1 and obj2
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 313 if numel(obj1) ~= numel(obj2)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 314 utils.helper.msg(msg.PROC1, 'NOT EQUAL: The size of the %s-object''s. [%d] <-> [%d]', class(obj1), numel(obj1), numel(obj2));
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 315 result = false;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 316 return
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 317 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 318
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 319 result = true;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 320
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 321 for ii = 1:numel(obj1)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 322
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 323 if isa(obj1{ii}, 'ltpda_obj')
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 324 %%%%%%%%%%%%% LTPDA objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 325 if ~eq(obj1{ii}, obj2{ii}, plist('exceptions', exception_list, 'tol', tol))
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 326 result = false;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 327 disaply_msg(obj1, ii, 'cell-object')
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 328 return
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 329 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 330
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 331 elseif isstruct(obj1{ii})
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 332 %%%%%%%%%%%%% STRUCTURE
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 333 if ~eqstruct(obj1{ii}, obj2{ii}, exception_list, tol)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 334 result = false;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 335 disaply_msg(obj1, ii, 'cell-object')
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 336 return
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 337 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 338
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 339 elseif iscell(obj1{ii})
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 340 %%%%%%%%%%%%% CELL
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 341 if ~eqcell(obj1{ii}, obj2{ii}, exception_list, tol)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 342 result = false;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 343 disaply_msg(obj1, ii, 'cell-object')
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 344 return
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 345 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 346
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 347 elseif isnumeric(obj1{ii})
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 348 %%%%%%%%%%%%% Numberic
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 349 if ~utils.math.isequal(obj1{ii}, obj2{ii}, tol)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 350 result = false;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 351 disaply_msg(obj1, ii, 'cell-object')
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 352 return
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 353 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 354
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 355 else
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 356 if ~isequal(obj1{ii}, obj2{ii})
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 357 result = false;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 358 disaply_msg(obj1, ii, 'cell-object')
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 359 return
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 360 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 361 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 362 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 363 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 364
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 365 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 366 %
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 367 % FUNCTION: eqparam
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 368 %
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 369 % DESCRIPTION: Equal method to compare param-objects. The order of the
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 370 % param-objects doesn't matter.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 371 %
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 372 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 373
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 374 function result = eqparam(obj1, obj2, exception_list, tol)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 375
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 376 import utils.const.*
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 377
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 378 %%%%% Check class
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 379 if ~strcmp(class(obj1), class(obj2))
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 380 utils.helper.msg(msg.PROC1, 'NOT EQUAL: The objects are not from the same class. [%s] <-> [%s]', class(obj1), class(obj2));
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 381 result = false;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 382 return
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 383 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 384
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 385 %%%%% Check length of obj1 and obj2
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 386 if numel(obj1) ~= numel(obj2)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 387 utils.helper.msg(msg.PROC1, 'NOT EQUAL: The size of the %s-object''s. [%d] <-> [%d]', class(obj1), numel(obj1), numel(obj2));
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 388 result = false;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 389 return
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 390 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 391
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 392 result = true;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 393
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 394 for oo = 1:numel(obj1)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 395
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 396 found = false;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 397 for ii = 1:numel(obj2)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 398
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 399 if strcmp(obj1(oo).key, obj2(ii).key)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 400 allparts = true;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 401 fields = fieldnames(obj1(oo));
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 402 for ff = 1:numel(fields)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 403 field = fields{ff};
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 404
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 405 ck_field = {field, sprintf('%s/%s', class(obj1), field)};
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 406 if ~(any(utils.helper.ismember(ck_field, exception_list)))
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 407
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 408 if strcmp(field, 'val')
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 409 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 410 %%% Compare only the current value
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 411 val1 = obj1(oo).getVal();
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 412 val2 = obj2(ii).getVal();
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 413 if isa(val1, 'ltpda_obj')
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 414 %%%%%%%%%%%%% LTPDA objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 415 allparts = allparts && eq(val1, val2, plist('exceptions', exception_list, 'tol', tol));
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 416
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 417 elseif isstruct(val1)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 418 %%%%%%%%%%%%% STRUCTURE
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 419 allparts = allparts && eqstruct(val1, val2, exception_list, tol);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 420
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 421 elseif iscell(val1)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 422 %%%%%%%%%%%%% CELL
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 423 allparts = allparts && eqcell(val1, val2, exception_list, tol);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 424 elseif isnumeric(val1)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 425 %%%%%%%%%%%%% Numeric
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 426 allparts = allparts && utils.math.isequal(val1, val2, tol);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 427 else
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 428 allparts = allparts && isequal(val1, val2);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 429 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 430
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 431 %%%%% Check the properties of the paramValue Object
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 432 if isa(obj1(oo).val, 'paramValue')
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 433 allparts = allparts && eqstruct(obj1(oo).val.property, obj2(ii).val.property, exception_list, tol);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 434 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 435
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 436 continue;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 437 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 438
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 439 if isa(obj1(oo).(field), 'ltpda_obj')
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 440 %%%%%%%%%%%%% LTPDA objects
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 441 allparts = allparts && eq(obj1(oo).(field), obj2(ii).(field), plist('exceptions', exception_list, 'tol', tol));
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 442
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 443 elseif isstruct(obj1(oo).(field))
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 444 %%%%%%%%%%%%% STRUCTURE
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 445 allparts = allparts && eqstruct(obj1(oo).(field), obj2(ii).(field), exception_list, tol);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 446
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 447 elseif iscell(obj1(oo).(field))
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 448 %%%%%%%%%%%%% CELL
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 449 allparts = allparts && eqcell(obj1(oo).(field), obj2(ii).(field), exception_list, tol);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 450
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 451 elseif isnumeric(obj1(oo).(field))
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 452 %%%%%%%%%%%%% Numeric
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 453 allparts = allparts && utils.math.isequal(obj1(oo).(field), obj2(ii).(field), tol);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 454 else
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 455 allparts = allparts && isequal(obj1(oo).(field), obj2(ii).(field));
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 456 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 457
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 458 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 459
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 460 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 461 if allparts
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 462 found = true;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 463 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 464 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 465
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 466 end % inner-loop
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 467
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 468 if ~found
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 469 result = false;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 470 disaply_msg(obj1, oo, ['key: ''' obj1(oo).key ''''])
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 471 return
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 472 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 473
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 474 end % outer-loop
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 475
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 476 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 477
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 478 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 479 %
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 480 % FUNCTION: getInfo
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 481 %
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 482 % DESCRIPTION: Get Info Object
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 483 %
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 484 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 485
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 486 function ii = getInfo(varargin)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 487 if nargin == 1 && strcmpi(varargin{1}, 'None')
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 488 sets = {};
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 489 pl = [];
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 490 else
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 491 sets = {'Default'};
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 492 pl = getDefaultPlist;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 493 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 494 % Build info object
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 495 ii = minfo(mfilename, 'plist', 'ltpda', utils.const.categories.relop, '$Id: eq.m,v 1.27 2011/04/08 08:56:21 hewitson Exp $', sets, pl);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 496 ii.setModifier(false);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 497 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 498
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 499 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 500 %
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 501 % FUNCTION: getDefaultPlist
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 502 %
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 503 % DESCRIPTION: Get Default Plist
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 504 %
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 505 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 506
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 507 function plo = getDefaultPlist()
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 508 plo = plist();
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 509
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 510 % Exceptions
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 511 p = param({'Exceptions', 'Test the objects without the given property names'}, paramValue.EMPTY_CELL);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 512 plo.append(p);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 513
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 514 % Tolerance
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 515 p = param({'Tol', 'Test double values with the given tolerance'}, paramValue.DOUBLE_VALUE(eps(1)));
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 516 plo.append(p);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 517
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 518 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 519