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.12 2007/09/27 09:03:25 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
0018 %                         i.e. 'nobalance' to disable balancing options are the
0019 %                               same as for the matlab function.
0020 %
0021 % VERSION:     $Id: eig.m,v 1.12 2007/09/27 09:03:25 ingo Exp $
0022 %
0023 % The following call returns a parameter list object that contains the
0024 % default parameter values:
0025 %
0026 % >> pl = eig(ao, 'Params')
0027 %
0028 % HISTORY: 08-05-07 A Monsky
0029 %             Creation
0030 %
0031 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0032 
0033 VERSION  = '$Id: eig.m,v 1.12 2007/09/27 09:03:25 ingo Exp $';
0034 
0035 %% Check if this is a call for parameters
0036 
0037 if nargin == 2
0038   if isa(varargin{1}, 'ao') && ischar(varargin{2})
0039     in = char(varargin{2});
0040     if strcmp(in, 'Params')
0041       varargout{1} = getDefaultPL();
0042       return
0043     elseif strcmp(in, 'Version')
0044       varargout{1} = VERSION;
0045       return
0046     end
0047   end
0048 end
0049 
0050 % capture input variable names
0051 invars = {};
0052 
0053 as = [];
0054 pl = [];
0055 V = [];
0056 D = [];
0057 vdata = [];
0058 ddata = [];
0059 
0060 for j=1:nargin
0061   invars = [invars cellstr(inputname(j))];
0062   if isa(varargin{j}, 'ao')
0063     as = [as varargin{j}];
0064   end
0065   if isa(varargin{j}, 'plist')
0066     pl = [pl varargin{j}];
0067   end
0068 end
0069 
0070 if ~isempty (pl)
0071   pl = combine(pl);
0072 end
0073 
0074 %% Loop over analysis objects
0075 for j=1:numel(as)
0076   a = as(j);
0077 
0078   d = get(a, 'data');
0079   dinfo = whos('d');
0080   % Which data type do we have
0081   dtype = dinfo.class;
0082 
0083   switch dtype
0084     case 'cdata'
0085       if size(d.vals,1) ~= size(d.vals,2)
0086         error('### The value (vals) of data must be a square matrix.')
0087       else
0088         disp('* Eigenvalues of cdata object');
0089         if nargout <= 1
0090           [h, vdata] = single_operation(d, 'eig',pl);
0091         elseif nargout == 2
0092           [h, vdata, ddata] = single_operation(d, 'eig',pl);
0093         end
0094         %create analysis object(s)
0095         h = set(h, 'inhists', [a.hist]);
0096 
0097         %% Set the var_name to the history
0098         if (j <= nargin)
0099           if (isempty (inputname(j)))
0100             h = set(h, 'invars', cellstr('no var_name'));
0101           else
0102             h = set(h, 'invars', cellstr(inputname(j)));
0103           end
0104         else
0105           h = set(h, 'invars', cellstr('no var_name'));
0106         end
0107 
0108         v = ao(vdata, h);
0109         v = set(v, 'name',  sprintf('v_eig(%s)', char(invars{1})));
0110         V = [V v];
0111         if ~isempty(ddata)
0112           d = ao(ddata, h);
0113           d = set(d, 'name',  sprintf('d_eig(%s)', char(invars{1})));
0114           D = [D d];
0115         end
0116       end
0117     case {'tsdata','fsdata','xydata'}
0118       error('### this function works for cdata type AO only')
0119     otherwise
0120       error('### unknown data type.')
0121   end
0122 end
0123 
0124 % Reshape the ouput to the same size of the input
0125 V = reshape(V, size(as));
0126 varargout{1} = V;
0127 
0128 if nargout > 1
0129   % Reshape the ouput to the same size of the input
0130   D = reshape(D, size(as));
0131   varargout{2} = D;
0132   if nargout > 2
0133     error('### wrong number of outputs')
0134   end
0135 end
0136 
0137 %% Get default params
0138 function plo = getDefaultPL()
0139 
0140 plo = plist();
0141 plo = append(plo, 'option', '');
0142 
0143 % END

Generated on Fri 02-Nov-2007 19:39:27 by m2html © 2003