Mercurial > hg > ltpda
comparison m-toolbox/classes/@ao/transpose.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 % TRANSPOSE overloads the .' operator for Analysis Objects. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: TRANSPOSE overloads the .' operator for Analysis Objects. | |
5 % | |
6 % CALL: a = a1.' | |
7 % | |
8 % <a href="matlab:utils.helper.displayMethodInfo('ao', 'transpose')">Parameter Sets</a> | |
9 % | |
10 % VERSION: $Id: transpose.m,v 1.38 2011/04/08 14:31:30 hewitson Exp $ | |
11 % | |
12 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
13 | |
14 function varargout = transpose(varargin) | |
15 | |
16 % Collect input variable names | |
17 in_names = cell(size(varargin)); | |
18 for ii = 1:nargin,in_names{ii} = inputname(ii);end | |
19 | |
20 % Check if this is a call for parameters | |
21 if utils.helper.isinfocall(varargin{:}) | |
22 varargout{1} = getInfo(varargin{3}); | |
23 return | |
24 end | |
25 | |
26 import utils.const.* | |
27 utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename); | |
28 | |
29 | |
30 % Collect all AOs | |
31 [as, ao_invars] = utils.helper.collect_objects(varargin(:), 'ao', in_names); | |
32 pl = utils.helper.collect_objects(varargin(:), 'plist', in_names); | |
33 | |
34 % Decide on a deep copy or a modify | |
35 bs = copy(as, nargout); | |
36 | |
37 % Combine plists | |
38 pl = applyDefaults(getDefaultPlist, pl); | |
39 | |
40 if pl.find('complex') | |
41 fcn = 'ctranspose'; | |
42 else | |
43 fcn = 'transpose'; | |
44 end | |
45 | |
46 for kk = 1:numel(bs) | |
47 | |
48 % Special case for cdata-objects because this objects doesn't have x values | |
49 y = bs(kk).data.y; | |
50 dy = bs(kk).data.dy; | |
51 bs(kk).data.setY([]); | |
52 bs(kk).data.setDy([]); | |
53 bs(kk).data.setY(feval(fcn, y)); | |
54 bs(kk).data.setDy(feval(fcn, dy)); | |
55 | |
56 if isa(bs(kk).data, 'data2D') | |
57 | |
58 x = bs(kk).data.x; | |
59 dx = bs(kk).data.dx; | |
60 | |
61 % Set the y-value to an empty array because the y-data keeps always the same | |
62 % shape | |
63 bs(kk).data.setX([]); | |
64 bs(kk).data.setDx([]); | |
65 | |
66 bs(kk).data.setX(feval(fcn, x)); | |
67 bs(kk).data.setDx(feval(fcn, dx)); | |
68 | |
69 end | |
70 | |
71 % Set new AO name | |
72 bs(kk).name = ['transpose(' ao_invars{kk} ')']; | |
73 % Add history | |
74 bs(kk).addHistory(getInfo('None'), pl, ao_invars(kk), bs(kk).hist); | |
75 end | |
76 | |
77 % clear errors | |
78 bs.clearErrors(pl); | |
79 | |
80 % Set output | |
81 if nargout == numel(bs) | |
82 % List of outputs | |
83 for ii = 1:numel(bs) | |
84 varargout{ii} = bs(ii); | |
85 end | |
86 else | |
87 % Single output | |
88 varargout{1} = bs; | |
89 end | |
90 end | |
91 | |
92 %-------------------------------------------------------------------------- | |
93 % Get Info Object | |
94 %-------------------------------------------------------------------------- | |
95 function ii = getInfo(varargin) | |
96 if nargin == 1 && strcmpi(varargin{1}, 'None') | |
97 sets = {}; | |
98 pl = []; | |
99 else | |
100 sets = {'Default'}; | |
101 pl = getDefaultPlist; | |
102 end | |
103 % Build info object | |
104 ii = minfo(mfilename, 'ao', 'ltpda', utils.const.categories.op, '$Id: transpose.m,v 1.38 2011/04/08 14:31:30 hewitson Exp $', sets, pl); | |
105 end | |
106 | |
107 %-------------------------------------------------------------------------- | |
108 % Get Default Plist | |
109 %-------------------------------------------------------------------------- | |
110 function plout = getDefaultPlist() | |
111 persistent pl; | |
112 if exist('pl', 'var')==0 || isempty(pl) | |
113 pl = buildplist(); | |
114 end | |
115 plout = pl; | |
116 end | |
117 | |
118 function pl = buildplist() | |
119 pl = plist(); | |
120 | |
121 % complex | |
122 p = param({'complex', 'Use complex conjugate transpose'}, paramValue.FALSE_TRUE); | |
123 pl.append(p); | |
124 | |
125 end | |
126 | |
127 % END |