Mercurial > hg > ltpda
comparison m-toolbox/classes/@ao/diag.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 % DIAG overloads the diagonal operator for analysis objects. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: DIAG overloads the diagonal operator for analysis objects. | |
5 % | |
6 % CALL: b = diag (a) % only with data = cdata | |
7 % b = diag (a, pl) | |
8 % | |
9 % INPUTS: a - input analysis object | |
10 % pl - parameter list | |
11 % | |
12 % OUTPUTS: b - output analysis object | |
13 % | |
14 % <a href="matlab:utils.helper.displayMethodInfo('ao', 'diag')">Parameters Description</a> | |
15 % | |
16 % VERSION: $Id: diag.m,v 1.43 2011/04/19 18:48:11 ingo Exp $ | |
17 % | |
18 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
19 | |
20 function varargout = diag(varargin) | |
21 | |
22 % Check if the method was called by another method | |
23 callerIsMethod = utils.helper.callerIsMethod; | |
24 | |
25 % Settings | |
26 operatorName = 'diag'; | |
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 % Check that the data of the AOs is a square matrix | |
52 for ii=1:numel(as) | |
53 if size(as(ii).data.y,1) ~= size(as(ii).data.y,2) | |
54 error('### The y data must be a square matrix.') | |
55 end | |
56 end | |
57 | |
58 copyObjects = nargout>0; | |
59 | |
60 % Apply method to all AOs | |
61 [out, pl] = ao.applymethod(copyObjects, callerIsMethod, in_names, operatorName, dxFcn, @getInfo, @getDefaultPlist, varargin{:}); | |
62 | |
63 % Clear errors | |
64 out.clearErrors(pl); | |
65 | |
66 % set outputs | |
67 varargout = utils.helper.setoutputs(nargout, out); | |
68 | |
69 end | |
70 | |
71 %-------------------------------------------------------------------------- | |
72 % Get Info Object | |
73 %-------------------------------------------------------------------------- | |
74 function ii = getInfo(varargin) | |
75 | |
76 ii = minfo.getInfoAxis(mfilename, @getDefaultPlist, varargin); | |
77 end | |
78 | |
79 %-------------------------------------------------------------------------- | |
80 % Get Default Plist | |
81 %-------------------------------------------------------------------------- | |
82 | |
83 function plout = getDefaultPlist(set) | |
84 persistent pl; | |
85 persistent lastset; | |
86 if ~exist('pl', 'var') || isempty(pl) || ~strcmp(lastset, set) | |
87 pl = buildplist(set); | |
88 lastset = set; | |
89 end | |
90 plout = pl; | |
91 end | |
92 | |
93 function plout = buildplist(varargin) | |
94 plout = plist.getDefaultAxisPlist(varargin{:}); | |
95 plout.remove('option'); | |
96 p = param({'option', 'See help on MATLAB''s <a href="matlab:doc(''diag'')">diag</a>.'}, {1, {0}, paramValue.OPTIONAL}); | |
97 plout.append(p); | |
98 end |