MatrixBerryCore
CompEntity.m
Go to the documentation of this file.
1 classdef CompEntity<handle
2  properties (Access=protected)
3  alpha
4  end
5  %
6  methods
7  function self=CompEntity(alpha)
8  self.alpha=alpha;
9  end
10  function isOk=isequal(varargin)
11  sizeVec=size(varargin{1});
12  isOk=mxberry.core.checksize(varargin{2:end},sizeVec);
13  if isOk
14  isOkArr=eq(varargin{:});
15  isOk=all(isOkArr(:));
16  end
17  end
18  function isOk=isequaln(varargin)
19  isOk=isequal(varargin{:});
20  end
21  function isOk=isequalwithequalnans(varargin)
22  isOk=isequal(varargin{:});
23  end
24  function isPosArr=ne(self,otherObj)
25  isPosArr=compare(self,otherObj,@ne,false);
26  end
27  %
28  function isPosArr=eq(self,otherObj,varargin)
29  import mxberry.core.parseparext;
30  [~,~,isAsHandle]=parseparext(varargin,...
31  {'asHandle';false},0);
32  if isAsHandle
33  isPosArr=eq@handle(self,otherObj);
34  else
35  isPosArr=compare(self,otherObj,@eq,false);
36  end
37  end
38  %
39  function isPosArr=le(self,otherObj)
40  isPosArr=compare(self,otherObj,@le);
41  end
42  %
43  function isPosArr=lt(self,otherObj)
44  isPosArr=compare(self,otherObj,@lt);
45  end
46  %
47  function isPosArr=gt(self,otherObj)
48  isPosArr=compare(self,otherObj,@gt);
49  end
50  %
51  function isPosArr=ge(self,otherObj)
52  isPosArr=compare(self,otherObj,@ge);
53  end
54  %
55  function isEqArr=compare(self,otherObj,fComp,isCountEqHandles)
56  if nargin<4
57  isCountEqHandles=true;
58  end
59  %
60  isEqArr=false(size(self));
61  nLeftElems=numel(self);
62  nRightElems=numel(otherObj);
63  %
64  nResElems=max(nLeftElems,nRightElems);
65  for iElem=1:nResElems
66  iLeftElem=min(iElem,nLeftElems);
67  iRightElem=min(iElem,nRightElems);
68  %
69  isEqArr(iElem)=...
70  fComp(self(iLeftElem).alpha,...
71  otherObj(iRightElem).alpha);
72  end
73  nCalls=nResElems;
74  if ~isCountEqHandles
75  isEqHandleArr=eq(self,otherObj,'asHandle',true);
76  nCalls=nCalls-sum(isEqHandleArr(:));
77  end
78  incCounter(nCalls);
79  end
80  function disp(self)
81  valArr=arrayfun(@(x)x.alpha,self);
82  disp(valArr);
83  end
84  end
85  %
86 end
87 function incCounter(nCalls)
88 mxberry.core.test.aux.EqualCallCounter.incEqCounter(nCalls);
89 end
function parseparext(in args, in propNameValMat, in varargin)
PARSEPAREXT behaves in the same way as mxberry.core.parseparams but returns property values in a more...