comparison m-toolbox/classes/@ao/sqrt.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 % SQRT computes the square root of the data in the AO.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: SQRT computes the square root of the data in the AO.
5 %
6 % CALL: ao_out = sqrt(ao_in);
7 % ao_out = sqrt(ao_in, pl);
8 %
9 % <a href="matlab:utils.helper.displayMethodInfo('ao', 'sqrt')">Parameters Description</a>
10 %
11 % VERSION: $Id: sqrt.m,v 1.42 2011/04/19 18:48:11 ingo Exp $
12 %
13 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14
15 function varargout = sqrt(varargin)
16
17 % Check if the method was called by another method
18 callerIsMethod = utils.helper.callerIsMethod;
19
20 % Settings
21 operatorName = 'sqrt';
22 dxFcn = @(x,dx)abs(1./(2*sqrt(abs(x)))).*dx;
23
24 if callerIsMethod
25 in_names = {};
26 else
27 % Collect input variable names
28 in_names = cell(size(varargin));
29 for ii = 1:nargin,in_names{ii} = inputname(ii);end
30 end
31
32 copyObjects = nargout>0;
33 [bs, pl] = ao.applymethod(copyObjects, callerIsMethod, in_names, operatorName, dxFcn, @getInfo, @getDefaultPlist, varargin{:});
34
35 if isa(bs, 'ao')
36 % Set units
37 for ii = 1:numel(bs)
38 app_axis = pl.find('axis');
39 if any('X'==upper(app_axis))
40 bs(ii).data.setXunits(feval('sqrt', bs(ii).data.xunits));
41 end
42 if any('Y'==upper(app_axis))
43 bs(ii).data.setYunits(feval('sqrt', bs(ii).data.yunits));
44 end
45 if any('Z'==upper(app_axis))
46 bs(ii).data.setZunits(feval('sqrt', bs(ii).data.zunits));
47 end
48 end
49 end
50
51 % set outputs
52 varargout = utils.helper.setoutputs(nargout, bs);
53
54 end
55
56 %--------------------------------------------------------------------------
57 % Get Info Object
58 %--------------------------------------------------------------------------
59 function ii = getInfo(varargin)
60 ii = minfo.getInfoAxis(mfilename, @getDefaultPlist, varargin);
61 end
62
63 %--------------------------------------------------------------------------
64 % Get Default Plist
65 %--------------------------------------------------------------------------
66
67 function plout = getDefaultPlist(set)
68 persistent pl;
69 persistent lastset;
70 if ~exist('pl', 'var') || isempty(pl) || ~strcmp(lastset, set)
71 pl = buildplist(set);
72 lastset = set;
73 end
74 plout = pl;
75 end
76
77 function plout = buildplist(varargin)
78 plout = plist.getDefaultAxisPlist(varargin{:});
79 end
80