Home > classes > @ao > applyoperator.m

applyoperator

PURPOSE ^

APPLYOPERATOR to the analysis object

SYNOPSIS ^

function res = applyoperator(as, ao_invars, op, opsym, pl, info)

DESCRIPTION ^

 APPLYOPERATOR to the analysis object
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: APPLYOPERATOR to the analysis object
              Private AO function that applies the given operator to
              the given AOs. This is called by all the simple methods like
              plus, minus, mtimes etc.

 CALL:        as = applyoperator(as, ao_invars, op, opsym, pl, info)

 VERSION:     $Id: applyoperator.m,v 1.18 2008/09/05 14:13:00 hewitson Exp $

 HISTORY:     11-06-2008 Hewitson
                 Creation

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % APPLYOPERATOR to the analysis object
0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0003 %
0004 % DESCRIPTION: APPLYOPERATOR to the analysis object
0005 %              Private AO function that applies the given operator to
0006 %              the given AOs. This is called by all the simple methods like
0007 %              plus, minus, mtimes etc.
0008 %
0009 % CALL:        as = applyoperator(as, ao_invars, op, opsym, pl, info)
0010 %
0011 % VERSION:     $Id: applyoperator.m,v 1.18 2008/09/05 14:13:00 hewitson Exp $
0012 %
0013 % HISTORY:     11-06-2008 Hewitson
0014 %                 Creation
0015 %
0016 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0017 
0018 function res = applyoperator(as, ao_invars, op, opsym, pl, info)
0019 
0020   %% Initialise the result to the first input object
0021   res = as(1);
0022 
0023   %% go through the remaining analysis objects
0024   for j=2:numel(as)
0025 
0026     % Message
0027     utils.helper.msg(2, 'applying %s to %s and %s', op, res.name, as(j).name);
0028 
0029     % Compute operator of data
0030     yu1 = res.data.yunits;
0031     yu2 = as(j).data.yunits;
0032     res.data = applyoperator(res.data, as(j).data, pl, plist('op', op));
0033 
0034     % append history
0035     res.addHistory(info, pl, [{res.name} ao_invars(j)], [res.hist as(j).hist]);
0036 
0037     % Set new AO name
0038     if  (length(opsym) == 2 && opsym(1) == '.') || ...
0039         (length(opsym) == 1)
0040       res.setName(['(' res.name ')' opsym '(' ao_invars{j} ')'], 'internal');
0041     else
0042       res.setName([opsym '(' res.name ',' ao_invars{j} ')'], 'internal');
0043     end
0044 
0045     if any(strcmp(op, {'plus', 'minus'}))
0046       if isempty(res.data.yunits.strs)
0047         res.setYunits(as(j).data.yunits);
0048       elseif isempty(as(j).data.yunits.strs)
0049         % leave the units alone
0050       elseif res.data.yunits ~= as(j).data.yunits
0051         error(['### You can not apply ' opsym ' to data with different Y units']);
0052       end
0053     elseif ismethod('unit', op)
0054       % Set units
0055       if any(strcmp(op, {'mpower', 'power'}))
0056         res.setYunits(feval(op, yu1, as(j).data.getY), 'internal');
0057       else
0058         res.setYunits(feval(op, yu1, yu2), 'internal');
0059       end
0060     else
0061       warning('LTPDA:INFO', '### This method doesn''t exist in the units class. Please set the units yourself.');
0062     end
0063 
0064   end
0065 
0066 end
0067

Generated on Mon 08-Sep-2008 13:18:47 by m2html © 2003