Mercurial > hg > ltpda
comparison m-toolbox/classes/@ao/applyoperator.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 % APPLYOPERATOR to the analysis object | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: APPLYOPERATOR to the analysis object | |
5 % Private AO function that applies the given operator to | |
6 % the given AOs. This is called by all the simple methods like | |
7 % plus, minus, mtimes etc. | |
8 % | |
9 % CALL: as = applyoperator(callerIsMethod, as, ao_invars, op, opsym, pl, info) | |
10 % | |
11 % VERSION: $Id: applyoperator.m,v 1.27 2011/02/25 15:46:22 ingo Exp $ | |
12 % | |
13 % HISTORY: 11-06-2008 Hewitson | |
14 % Creation | |
15 % | |
16 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
17 | |
18 function res = applyoperator(as, callerIsMethod, ao_invars, op, opsym, pl, info) | |
19 | |
20 %% Initialise the result to the first input object | |
21 res = as(1); | |
22 | |
23 %% go through the remaining analysis objects | |
24 for jj = 2:numel(as) | |
25 | |
26 % Message | |
27 utils.helper.msg(2, 'applying %s to %s and %s', op, res.name, as(jj).name); | |
28 | |
29 % Compute operator of data | |
30 yu1 = res.data.yunits; | |
31 yu2 = as(jj).data.yunits; | |
32 res.data = applyoperator(res.data, as(jj).data, op); | |
33 | |
34 if callerIsMethod | |
35 % do nothing | |
36 else | |
37 % append history | |
38 res.addHistory(info, pl, [{res.name} ao_invars(jj)], [res.hist as(jj).hist]); | |
39 | |
40 % Set new AO name | |
41 if (length(opsym) == 2 && opsym(1) == '.') || ... | |
42 (length(opsym) == 1) | |
43 res.name = ['(' res.name ')' opsym '(' ao_invars{jj} ')']; | |
44 else | |
45 res.name = [opsym '(' res.name ',' ao_invars{jj} ')']; | |
46 end | |
47 end | |
48 | |
49 if any(strcmp(op, {'plus', 'minus'})) | |
50 % Do nothing | |
51 elseif ismethod('unit', op) | |
52 % Set units | |
53 if any(strcmp(op, {'mpower', 'power'})) | |
54 if numel(as(jj).data.getY) == 1 | |
55 res.data.setYunits(feval(op, yu1, as(jj).data.getY)); | |
56 else | |
57 end | |
58 else | |
59 res.data.setYunits(feval(op, yu1, yu2)); | |
60 end | |
61 else | |
62 warning('LTPDA:INFO', '### This method doesn''t exist in the units class. Please set the units yourself.'); | |
63 end | |
64 | |
65 end | |
66 | |
67 end | |
68 |