comparison m-toolbox/classes/@matrix/minus.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1 % MINUS implements subtraction operator for ltpda model objects.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: MINUS implements subtraction operator for two matrix objects.
5 %
6 % CALL: obj = obj1-obj2
7 % obj = minus(obj1,obj2);
8 % obj = minus(obj1,obj2,obj3) == minus(minus(obj1,obj2),obj3)
9 %
10 % REMARK: More than two inputs are handled with nested calls.
11 % (This doesn't work at the moment. Do we need this?)
12 %
13 % <a href="matlab:utils.helper.displayMethodInfo('matrix', 'minus')">Parameters Description</a>
14 %
15 % VERSION: $Id: minus.m,v 1.8 2011/04/08 08:56:32 hewitson Exp $
16 %
17 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
18
19 function varargout = minus(varargin)
20
21 callerIsMethod = utils.helper.callerIsMethod;
22
23 % Check if this is a call for parameters
24 if utils.helper.isinfocall(varargin{:})
25 varargout{1} = getInfo(varargin{3});
26 return
27 end
28
29 if nargout == 0
30 error('### Subtraction operator can not be used as a modifier.');
31 end
32
33 op = 'minus';
34 opname = 'subtraction';
35 opsym = '-';
36 infoObj = getInfo('None');
37
38 % collect input variable names
39 in_names = cell(size(varargin));
40 for ii = 1:nargin,if ~isa(varargin{ii}, 'plist'), in_names{ii} = inputname(ii); end, end
41
42 % Collect all plists
43 [pl, pl_invars, rest] = utils.helper.collect_objects(varargin(:), 'plist', in_names);
44
45 % Combine default plist
46 pl = combine(pl, getDefaultPlist());
47
48 mat = matrix.elementOp(callerIsMethod, op, opname, opsym, infoObj, pl, rest, in_names);
49
50 %%%%%%%%%% Prepare output %%%%%%%%%%
51 if nargout == numel(mat)
52 for kk=1:numel(mat)
53 varargout{kk} = mat(kk);
54 end
55 else
56 varargout{1} = mat;
57 end
58 end
59
60 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
61 % Local Functions %
62 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
63
64 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
65 %
66 % FUNCTION: getInfo
67 %
68 % DESCRIPTION: Get Info Object
69 %
70 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
71
72 function ii = getInfo(varargin)
73
74 if nargin == 1 && strcmpi(varargin{1}, 'None')
75 sets = {};
76 pls = [];
77 else
78 sets = {'Default'};
79 pls = getDefaultPlist;
80 end
81 % Build info object
82 ii = minfo(mfilename, 'matrix', 'ltpda', utils.const.categories.aop, '$Id: minus.m,v 1.8 2011/04/08 08:56:32 hewitson Exp $', sets, pls);
83 ii.setArgsmin(2);
84 ii.setModifier(false);
85 end
86
87 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
88 %
89 % FUNCTION: getDefaultPlist
90 %
91 % DESCRIPTION: Get Default Plist
92 %
93 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
94
95 function plout = getDefaultPlist()
96 persistent pl;
97 if exist('pl', 'var')==0 || isempty(pl)
98 pl = buildplist();
99 end
100 plout = pl;
101 end
102
103 function pl = buildplist()
104 pl = plist.EMPTY_PLIST;
105 end