Mercurial > hg > ltpda
comparison m-toolbox/classes/@matrix/rdivide.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 % RDIVIDE implements division operator for matrix objects. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: RDIVIDE implements division operator for two matrix objects. | |
5 % | |
6 % CALL: obj = obj1./obj2 | |
7 % obj = rdivide(obj1,obj2); | |
8 % obj = rdivide(obj1,obj2,obj3) == rdivide(rdivide(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', 'rdivide')">Parameters Description</a> | |
14 % | |
15 % VERSION: $Id: rdivide.m,v 1.8 2011/04/08 08:56:31 hewitson Exp $ | |
16 % | |
17 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
18 | |
19 function varargout = rdivide(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('### Division operator can not be used as a modifier.'); | |
31 end | |
32 | |
33 op = 'rdivide'; | |
34 opname = 'dividion'; | |
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 | |
59 end | |
60 | |
61 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
62 % Local Functions % | |
63 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
64 | |
65 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
66 % | |
67 % FUNCTION: getInfo | |
68 % | |
69 % DESCRIPTION: Get Info Object | |
70 % | |
71 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
72 | |
73 function ii = getInfo(varargin) | |
74 | |
75 if nargin == 1 && strcmpi(varargin{1}, 'None') | |
76 sets = {}; | |
77 pls = []; | |
78 else | |
79 sets = {'Default'}; | |
80 pls = getDefaultPlist; | |
81 end | |
82 % Build info object | |
83 ii = minfo(mfilename, 'matrix', 'ltpda', utils.const.categories.aop, '$Id: rdivide.m,v 1.8 2011/04/08 08:56:31 hewitson Exp $', sets, pls); | |
84 ii.setArgsmin(2); | |
85 ii.setModifier(false); | |
86 end | |
87 | |
88 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
89 % | |
90 % FUNCTION: getDefaultPlist | |
91 % | |
92 % DESCRIPTION: Get Default Plist | |
93 % | |
94 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
95 | |
96 function plout = getDefaultPlist() | |
97 persistent pl; | |
98 if exist('pl', 'var')==0 || isempty(pl) | |
99 pl = buildplist(); | |
100 end | |
101 plout = pl; | |
102 end | |
103 | |
104 function pl = buildplist() | |
105 pl = plist.EMPTY_PLIST; | |
106 end |