Mercurial > hg > ltpda
comparison m-toolbox/classes/@ao/norm.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 % NORM overloads the norm operator for Analysis Objects. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: NORM overloads the norm operator for Analysis Objects. | |
5 % | |
6 % CALL: b = norm (a,pl) % only with data = cdata | |
7 % b = norm (a) | |
8 % | |
9 % INPUTS: pl - a parameter list | |
10 % a - input analysis object | |
11 % | |
12 % OUTPUTS: See MATLAB's norm. | |
13 % | |
14 % <a href="matlab:utils.helper.displayMethodInfo('ao', 'norm')">Parameters Description</a> | |
15 % | |
16 % VERSION: $Id: norm.m,v 1.40 2011/04/19 18:48:11 ingo Exp $ | |
17 % | |
18 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
19 | |
20 function varargout = norm(varargin) | |
21 | |
22 % Check if the method was called by another method | |
23 callerIsMethod = utils.helper.callerIsMethod; | |
24 | |
25 % Settings | |
26 operatorName = 'norm'; | |
27 dxFcn = []; | |
28 | |
29 if callerIsMethod | |
30 in_names = {}; | |
31 else | |
32 % Collect input variable names | |
33 in_names = cell(size(varargin)); | |
34 for ii = 1:nargin,in_names{ii} = inputname(ii);end | |
35 | |
36 % Check if this is a call for the minfo object | |
37 if utils.helper.isinfocall(varargin{:}) | |
38 varargout{1} = getInfo(varargin{3}); | |
39 return | |
40 end | |
41 | |
42 end | |
43 | |
44 % Here we are forced to collect objects so that we can check that each ao | |
45 % is the correct type and shape for doing det. | |
46 [as, dummy, rest] = utils.helper.collect_objects(varargin, 'ao', in_names); | |
47 | |
48 % Check for the correct data objects: Throw an error for data2D objects. | |
49 as.checkDataType('data2D'); | |
50 | |
51 copyObjects = nargout>0; | |
52 | |
53 % Apply method to all AOs | |
54 [out, pl] = ao.applymethod(copyObjects, callerIsMethod, in_names, operatorName, dxFcn, @getInfo, @getDefaultPlist, varargin{:}); | |
55 | |
56 % Clear errors | |
57 out.clearErrors(pl); | |
58 | |
59 % set outputs | |
60 varargout = utils.helper.setoutputs(nargout, out); | |
61 | |
62 end | |
63 %-------------------------------------------------------------------------- | |
64 % Get Info Object | |
65 %-------------------------------------------------------------------------- | |
66 function ii = getInfo(varargin) | |
67 ii = minfo.getInfoAxis(mfilename, @getDefaultPlist, varargin); | |
68 end | |
69 | |
70 %-------------------------------------------------------------------------- | |
71 % Get Default Plist | |
72 %-------------------------------------------------------------------------- | |
73 | |
74 function plout = getDefaultPlist(set) | |
75 persistent pl; | |
76 persistent lastset; | |
77 if ~exist('pl', 'var') || isempty(pl) || ~strcmp(lastset, set) | |
78 pl = buildplist(set); | |
79 lastset = set; | |
80 end | |
81 plout = pl; | |
82 end | |
83 | |
84 function plout = buildplist(varargin) | |
85 plout = plist.getDefaultAxisPlist(varargin{:}); | |
86 | |
87 % Option | |
88 p = param({'option', ['A string or value that can be submited, e.g. ''inf'' for<br>'... | |
89 'the infinity norm of the input ao, the largest row<br>'... | |
90 'sum. Options are the same as for MATLAB''s norm.']}, paramValue.EMPTY_STRING); | |
91 plout.remove('option'); | |
92 plout.append(p); | |
93 end |