view m-toolbox/classes/@ao/power.m @ 29:54f14716c721 database-connection-manager

Update Java code
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Mon, 05 Dec 2011 16:20:06 +0100
parents f0afece42f48
children
line wrap: on
line source

% POWER implements power operator for analysis objects.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% DESCRIPTION: POWER implements power operator for analysis objects.
%
% CALL:        a = a1.^scalar
%              a = a1.^a2
%
% <a href="matlab:utils.helper.displayMethodInfo('ao', 'power')">Parameters Description</a>
%
% VERSION:     $Id: power.m,v 1.35 2011/04/08 08:56:16 hewitson Exp $
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function varargout = power(varargin)

  import utils.const.*
  
  callerIsMethod = utils.helper.callerIsMethod;
  
  operatorName   = 'power';
  operatorSymbol = '.^';
  
  % Check if this is a call for parameters
  if utils.helper.isinfocall(varargin{:})
    varargout{1} = getInfo(varargin{3});
    return
  end

  utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename);

  % Collect input aos, plists and ao variable names
  in_names = cell(size(varargin));
  for ii = 1:nargin,in_names{ii} = inputname(ii);end

  % Check for numbers in the other arguments and convert to AOs
  args = utils.helper.collect_values(varargin);
  [as, ao_invars] = utils.helper.collect_objects(args, 'ao', in_names);
  pl              = utils.helper.collect_objects(args, 'plist');

  % Combine with default plist
  pl = parse(pl, getDefaultPlist);

  % Decide on a deep copy or a modify
  bs = copy(as, nargout);
  
  % Settings
  if callerIsMethod
    infoObj = [];
  else
    infoObj = getInfo();
  end
  
  if ~isempty(pl.find('exponent'))
    bs = [reshape(bs, [], 1), ao(pl.find('exponent'))];
    ao_invars{end+1} = mat2str(pl.find('exponent'));
  end
  
  % Apply method and set output
  varargout{1} = bs.applyoperator(callerIsMethod, ao_invars, operatorName, operatorSymbol, pl, infoObj);
end

%--------------------------------------------------------------------------
% Get Info Object
%--------------------------------------------------------------------------
function ii = getInfo(varargin)
  if nargin == 1 && strcmpi(varargin{1}, 'None')
    sets = {};
    pl   = [];
  else
    sets = {'Default'};
    pl   = getDefaultPlist;
  end
  % Build info object
  ii = minfo(mfilename, 'ao', 'ltpda', utils.const.categories.aop, '$Id: power.m,v 1.35 2011/04/08 08:56:16 hewitson Exp $', sets, pl);
  ii.setArgsmin(2);
end

%--------------------------------------------------------------------------
% Get Default Plist
%--------------------------------------------------------------------------
function plout = getDefaultPlist()
  persistent pl;  
  if ~exist('pl', 'var') || isempty(pl)
    pl = buildplist();
  end
  plout = pl;  
end

function pl = buildplist()
  pl = plist({'exponent', 'The exponent.'}, paramValue.EMPTY_DOUBLE);
end