Mercurial > hg > ltpda
comparison m-toolbox/classes/@matrix/times.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 % TIMES implements multiplication operator for matrix objects. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: TIMES implements multiplication operator for matrix objects. | |
5 % | |
6 % CALL: obj = obj1 .* obj2 | |
7 % obj = times(obj1,obj2); | |
8 % obj = times(obj1,obj2,obj3) == times(times(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', 'times')">Parameters Description</a> | |
14 % | |
15 % VERSION: $Id: times.m,v 1.8 2011/04/08 08:56:31 hewitson Exp $ | |
16 % | |
17 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
18 | |
19 function varargout = times(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('### Matrix multiplication operator can not be used as a modifier.'); | |
31 end | |
32 | |
33 op = 'times'; | |
34 opname = 'multiplication'; | |
35 opsym = '.*'; | |
36 infoObj = getInfo('None'); | |
37 | |
38 % collect input variable names | |
39 if callerIsMethod | |
40 in_names = {}; | |
41 pl = []; | |
42 rest = varargin(:); | |
43 else | |
44 in_names = cell(size(varargin)); | |
45 for ii = 1:nargin,if ~isa(varargin{ii}, 'plist'), in_names{ii} = inputname(ii); end, end | |
46 | |
47 % Collect all plists | |
48 [pl, pl_invars, rest] = utils.helper.collect_objects(varargin(:), 'plist', in_names); | |
49 | |
50 % Combine default plist | |
51 pl = combine(pl, getDefaultPlist()); | |
52 end | |
53 | |
54 mat = matrix.elementOp(callerIsMethod, op, opname, opsym, infoObj, pl, rest, in_names); | |
55 | |
56 | |
57 %%%%%%%%%% Prepare output %%%%%%%%%% | |
58 if nargout == numel(mat) | |
59 for kk=1:numel(mat) | |
60 varargout{kk} = mat(kk); | |
61 end | |
62 else | |
63 varargout{1} = mat; | |
64 end | |
65 | |
66 end | |
67 | |
68 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
69 % Local Functions % | |
70 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
71 | |
72 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
73 % | |
74 % FUNCTION: getInfo | |
75 % | |
76 % DESCRIPTION: Get Info Object | |
77 % | |
78 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
79 | |
80 function ii = getInfo(varargin) | |
81 | |
82 if nargin == 1 && strcmpi(varargin{1}, 'None') | |
83 sets = {}; | |
84 pls = []; | |
85 else | |
86 sets = {'Default'}; | |
87 pls = getDefaultPlist; | |
88 end | |
89 % Build info object | |
90 ii = minfo(mfilename, 'matrix', 'ltpda', utils.const.categories.aop, '$Id: times.m,v 1.8 2011/04/08 08:56:31 hewitson Exp $', sets, pls); | |
91 ii.setArgsmin(2); | |
92 ii.setModifier(false); | |
93 end | |
94 | |
95 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
96 % | |
97 % FUNCTION: getDefaultPlist | |
98 % | |
99 % DESCRIPTION: Get Default Plist | |
100 % | |
101 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
102 | |
103 function plout = getDefaultPlist() | |
104 persistent pl; | |
105 if exist('pl', 'var')==0 || isempty(pl) | |
106 pl = buildplist(); | |
107 end | |
108 plout = pl; | |
109 end | |
110 | |
111 function pl = buildplist() | |
112 pl = plist.EMPTY_PLIST; | |
113 end |