Home > classes > @ao > eig.m

eig

PURPOSE ^

EIG overloads the determinant function for Analysis objects.

SYNOPSIS ^

function varargout = eig(varargin)

DESCRIPTION ^

 EIG overloads the determinant function for Analysis objects.

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

 DESCRIPTION: EIG overloads the determinant function for Analysis objects.

 CALL:        v     = svd (a,pl)    % only with data = cdata
             [v, d] = svd (a,pl)
             [v, d] = svd (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. 'nobalance' to disable balancing
                         options are the same as for the matlab function

 VERSION:     $Id: eig.m,v 1.7 2007/06/22 08:32:49 ingo Exp $

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

 >> pl = eig(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 = eig(varargin)
0002 % EIG overloads the determinant function for Analysis objects.
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: EIG overloads the determinant function for Analysis objects.
0007 %
0008 % CALL:        v     = svd (a,pl)    % only with data = cdata
0009 %             [v, d] = svd (a,pl)
0010 %             [v, d] = svd (a)
0011 %
0012 % INPUTS:      pl   - a parameter list
0013 %              a    - input analysis object
0014 %
0015 % OUTPUTS:     like matlab fct
0016 %
0017 % Parameters:  'option' - a string or value that can be submited  i.e. 'nobalance' to disable balancing
0018 %                         options are the same as for the matlab function
0019 %
0020 % VERSION:     $Id: eig.m,v 1.7 2007/06/22 08:32:49 ingo Exp $
0021 %
0022 % The following call returns a parameter list object that contains the
0023 % default parameter values:
0024 %
0025 % >> pl = eig(ao, 'Params')
0026 %
0027 % HISTORY: 08-05-07 A Monsky
0028 %             Creation
0029 %
0030 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0031 
0032 %% Check if this is a call for parameters
0033 
0034 if nargin == 2
0035   if isa(varargin{1}, 'ao') && ischar(varargin{2})
0036     in = char(varargin{2});
0037     if strcmp(in, 'Params')
0038       varargout{1} = getDefaultPL();
0039       return
0040     end
0041   end
0042 end
0043 
0044 % capture input variable names
0045 invars = {};
0046 ALGONAME = mfilename;
0047 VERSION  = '$Id: eig.m,v 1.7 2007/06/22 08:32:49 ingo Exp $';
0048 
0049 as = [];
0050 ps = [];
0051 V = [];
0052 D = [];
0053 vdata = [];
0054 ddata = [];
0055 
0056 for j=1:nargin
0057   invars = [invars cellstr(inputname(j))];
0058   if isa(varargin{j}, 'ao')
0059     as = [as varargin{j}];
0060   end
0061   if isa(varargin{j}, 'plist')
0062     ps = [ps varargin{j}];
0063   end
0064 end
0065 
0066 
0067 
0068 %% go through analysis objects
0069 
0070 for j=1:nargin
0071     a = varargin{j};
0072     if isa(a, 'ao')
0073         as = [as a];
0074     elseif isa(a, 'plist')
0075         ps = [ps a];
0076 %     else
0077 %         option = [option a];
0078     end
0079 end
0080 % check plist
0081 if isempty(ps)
0082   pl = getDefaultPL();
0083 else
0084   pl = combine(ps, getDefaultPL);
0085 end
0086 
0087 %% Loop over analysis objects
0088 for j=1:length(as)
0089   a = as(j);
0090 
0091   d = get(a, 'data');
0092   dinfo = whos('d');
0093   % Which data type do we have
0094   dtype = dinfo.class;
0095 
0096   switch dtype
0097     case 'cdata'
0098       disp('* Eigenvalues of cdata object');
0099       if nargout <= 1
0100         [h, vdata] = single_operation(d, 'eig',pl);
0101       elseif nargout == 2
0102         [h, vdata, ddata] = single_operation(d, 'eig',pl);
0103       end
0104       %create analysis object(s)
0105       h = set(h, 'invars', [a.hist]);
0106       v = ao(vdata, h);
0107       v = set(v, 'name',  sprintf('v_eig(%s)', char(invars{1})));
0108       V = [V v];
0109       if ~isempty(ddata)
0110         d = ao(ddata, h);
0111         d = set(d, 'name',  sprintf('d_eig(%s)', char(invars{1})));
0112         D = [D d];
0113       end
0114     case {'tsdata','fsdata','xydata'}
0115       error('### this function works for cdata type AO only')
0116     otherwise
0117       error('### unknown data type.')
0118   end
0119 end
0120 
0121 varargout{1} = V;
0122 if nargout > 1
0123   varargout{2} = D;
0124   if nargout > 2
0125     error('### wrong number of outputs')
0126   end
0127 end
0128 
0129 %% Get default params
0130 function plo = getDefaultPL()
0131 
0132 disp('* creating default plist...');
0133 plo = plist();
0134 disp('* done.');
0135 
0136 % END

Generated on Mon 02-Jul-2007 12:19:41 by m2html © 2003