Home > classes > @ao > norm.m

norm

PURPOSE ^

NORM overloads the norm operator for Analysis Objects.

SYNOPSIS ^

function varargout = norm(varargin)

DESCRIPTION ^

 NORM overloads the norm operator for Analysis Objects.

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

 DESCRIPTION:NORM overloads the norm operator for Analysis Objects.

 CALL:        b = norm (a,pl)
              b = norm (a)

 INPUTS:      pl   - a parameter list
              a    - input analysis object

 OUTPUTS:     like matlab fct

 Parameters: 'option' - a string or value that can be submited  i.e. 'inf' for the infinity norm of the input ao, the largest row sum
                        options are the same as for the matlab function

 VERSION:     $Id: norm.m,v 1.9 2007/07/12 15:56:44 ingo Exp $

 The following call returns a parameter list object that contains the
 default parameter values:

 >> pl = norm(ao, 'Params')

 HISTORY: 08-05-07 A Monsky
             Creation

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function varargout = norm(varargin)
0002 % NORM overloads the norm operator for Analysis Objects.
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION:NORM overloads the norm operator for Analysis Objects.
0007 %
0008 % CALL:        b = norm (a,pl)
0009 %              b = norm (a)
0010 %
0011 % INPUTS:      pl   - a parameter list
0012 %              a    - input analysis object
0013 %
0014 % OUTPUTS:     like matlab fct
0015 %
0016 % Parameters: 'option' - a string or value that can be submited  i.e. 'inf' for the infinity norm of the input ao, the largest row sum
0017 %                        options are the same as for the matlab function
0018 %
0019 % VERSION:     $Id: norm.m,v 1.9 2007/07/12 15:56:44 ingo Exp $
0020 %
0021 % The following call returns a parameter list object that contains the
0022 % default parameter values:
0023 %
0024 % >> pl = norm(ao, 'Params')
0025 %
0026 % HISTORY: 08-05-07 A Monsky
0027 %             Creation
0028 %
0029 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0030 
0031 %% Check if this is a call for parameters
0032 
0033 if nargin == 2
0034   if isa(varargin{1}, 'ao') && ischar(varargin{2})
0035     in = char(varargin{2});
0036     if strcmp(in, 'Params')
0037       varargout{1} = getDefaultPL();
0038       return
0039     end
0040   end
0041 end
0042 
0043 % capture input variable names
0044 invars = {};
0045 
0046 ALGONAME = mfilename;
0047 VERSION  = '$Id: norm.m,v 1.9 2007/07/12 15:56:44 ingo Exp $';
0048 
0049 as = [];
0050 pl = [];
0051 bs = [];
0052 
0053 for j=1:nargin
0054   invars = [invars cellstr(inputname(j))];
0055   if isa(varargin{j}, 'ao')
0056     as = [as varargin{j}];
0057   end
0058   if isa(varargin{j}, 'plist')
0059     pl = [pl varargin{j}];
0060   end
0061 end
0062 
0063 if ~isempty (pl)
0064   pl = combine(pl);
0065 end
0066 
0067 
0068 %% go through analysis objects
0069 for j=1:length(as)
0070   a = as(j);
0071 
0072   d = get(a, 'data');
0073   dinfo = whos('d');
0074   % Which data type do we have
0075   dtype = dinfo.class;
0076   switch dtype
0077     case 'cdata'
0078       disp('* NORM of cdata object');
0079       % make a new cdata object
0080       [h, c] = single_operation(d, 'norm',pl);
0081 
0082       % make output analysis object
0083       h = set(h, 'invars', [a.hist]);
0084       b = ao(c, h);
0085       b = set(b, 'name',  sprintf('norm(%s)', char(invars{1})));
0086     case {'tsdata','fsdata','xydata'}
0087       error('### this function works for cdata type AO only')
0088     otherwise
0089       error('### unknown data type.')
0090 
0091   end
0092 
0093   % add to output
0094   bs = [bs b];
0095 end
0096 varargout{1} = bs;
0097 %% Get default params
0098 function plo = getDefaultPL()
0099 
0100 disp('* creating default plist...');
0101 plo = plist();
0102 plo = append(plo, 'option', []);
0103 disp('* done.');
0104 
0105 
0106 % END

Generated on Mon 03-Sep-2007 12:12:34 by m2html © 2003