comparison m-toolbox/classes/@ao/mpower.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 % MPOWER implements mpower operator for analysis objects.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: MPOWER implements mpower operator for analysis objects.
5 %
6 % CALL: a = a1^scalar
7 % a = a1^a2
8 %
9 % <a href="matlab:utils.helper.displayMethodInfo('ao', 'mpower')">Parameters Description</a>
10 %
11 % VERSION: $Id: mpower.m,v 1.36 2011/04/08 08:56:15 hewitson Exp $
12 %
13 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14
15 function varargout = mpower(varargin)
16
17 import utils.const.*
18
19 callerIsMethod = utils.helper.callerIsMethod;
20
21 operatorName = 'mpower';
22 operatorSymbol = '^';
23
24 % Check if this is a call for parameters
25 if utils.helper.isinfocall(varargin{:})
26 varargout{1} = getInfo(varargin{3});
27 return
28 end
29
30 utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename);
31
32 % Collect input aos, plists and ao variable names
33 in_names = cell(size(varargin));
34 for ii = 1:nargin,in_names{ii} = inputname(ii);end
35
36 % Check for numbers in the other arguments and convert to AOs
37 args = utils.helper.collect_values(varargin);
38 [as, ao_invars] = utils.helper.collect_objects(args, 'ao', in_names);
39 pl = utils.helper.collect_objects(args, 'plist');
40
41 % Combine with default plist
42 pl = parse(pl, getDefaultPlist);
43
44 % Decide on a deep copy or a modify
45 bs = copy(as, nargout);
46
47 % Settings
48 if callerIsMethod
49 infoObj = [];
50 else
51 infoObj = getInfo();
52 end
53
54 if ~isempty(pl.find('exponent'))
55 bs = [reshape(bs, [], 1), ao(pl.find('exponent'))];
56 ao_invars{end+1} = mat2str(pl.find('exponent'));
57 end
58
59 % Apply method and set output
60 varargout{1} = bs.applyoperator(callerIsMethod, ao_invars, operatorName, operatorSymbol, pl, infoObj);
61 end
62
63 %--------------------------------------------------------------------------
64 % Get Info Object
65 %--------------------------------------------------------------------------
66 function ii = getInfo(varargin)
67 if nargin == 1 && strcmpi(varargin{1}, 'None')
68 sets = {};
69 pl = [];
70 else
71 sets = {'Default'};
72 pl = getDefaultPlist;
73 end
74 % Build info object
75 ii = minfo(mfilename, 'ao', 'ltpda', utils.const.categories.aop, '$Id: mpower.m,v 1.36 2011/04/08 08:56:15 hewitson Exp $', sets, pl);
76 ii.setArgsmin(2);
77 end
78
79 %--------------------------------------------------------------------------
80 % Get Default Plist
81 %--------------------------------------------------------------------------
82 function plout = getDefaultPlist()
83 persistent pl;
84 if ~exist('pl', 'var') || isempty(pl)
85 pl = buildplist();
86 end
87 plout = pl;
88 end
89
90 function pl = buildplist()
91 pl = plist({'exponent', 'The exponent.'}, paramValue.EMPTY_DOUBLE);
92 end
93
94