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.8 2007/07/12 15:56:44 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.8 2007/07/12 15:56:44 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.8 2007/07/12 15:56:44 ingo Exp $';
0048 
0049 as = [];
0050 pl = [];
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     pl = [pl varargin{j}];
0063   end
0064 end
0065 
0066 if ~isempty (pl)
0067   pl = combine(pl);
0068 end
0069 
0070 %% Loop over analysis objects
0071 for j=1:length(as)
0072   a = as(j);
0073 
0074   d = get(a, 'data');
0075   dinfo = whos('d');
0076   % Which data type do we have
0077   dtype = dinfo.class;
0078 
0079   switch dtype
0080     case 'cdata'
0081       disp('* Eigenvalues of cdata object');
0082       if nargout <= 1
0083         [h, vdata] = single_operation(d, 'eig',pl);
0084       elseif nargout == 2
0085         [h, vdata, ddata] = single_operation(d, 'eig',pl);
0086       end
0087       %create analysis object(s)
0088       h = set(h, 'invars', [a.hist]);
0089       v = ao(vdata, h);
0090       v = set(v, 'name',  sprintf('v_eig(%s)', char(invars{1})));
0091       V = [V v];
0092       if ~isempty(ddata)
0093         d = ao(ddata, h);
0094         d = set(d, 'name',  sprintf('d_eig(%s)', char(invars{1})));
0095         D = [D d];
0096       end
0097     case {'tsdata','fsdata','xydata'}
0098       error('### this function works for cdata type AO only')
0099     otherwise
0100       error('### unknown data type.')
0101   end
0102 end
0103 
0104 varargout{1} = V;
0105 if nargout > 1
0106   varargout{2} = D;
0107   if nargout > 2
0108     error('### wrong number of outputs')
0109   end
0110 end
0111 
0112 %% Get default params
0113 function plo = getDefaultPL()
0114 
0115 disp('* creating default plist...');
0116 plo = plist();
0117 plo = append(plo, 'option', '');
0118 disp('* done.');
0119 
0120 % END

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