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.17 2008/01/10 21:25:04 hewitson 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.17 2008/01/10 21:25:04 hewitson 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.17 2008/01/10 21:25:04 hewitson Exp $';
0034 vdata   = [];
0035 ddata   = [];
0036 V       = [];
0037 D       = [];
0038 
0039 %% Check if this is a call for parameters
0040 
0041 if nargin == 2
0042   if isa(varargin{1}, 'ao') && ischar(varargin{2})
0043     in = char(varargin{2});
0044     if strcmp(in, 'Params')
0045       varargout{1} = getDefaultPL();
0046       return
0047     elseif strcmp(in, 'Version')
0048       varargout{1} = VERSION;
0049       return
0050     end
0051   end
0052 end
0053 
0054 %% Collect input ao's, plist's and ao variable names
0055 in_names = {};
0056 for ii = 1:nargin
0057   in_names{end+1} = inputname(ii);
0058 end
0059 
0060 [as, pl, invars] = collect_inputs(varargin, in_names);
0061 
0062 if ~isempty (pl)
0063   pl = combine(pl);
0064 end
0065 
0066 %% Loop over analysis objects
0067 for j=1:numel(as)
0068   a = as(j);
0069 
0070   d = get(a, 'data');
0071   dinfo = whos('d');
0072   % Which data type do we have
0073   dtype = dinfo.class;
0074 
0075   switch dtype
0076     case 'cdata'
0077       if size(d.y,1) ~= size(d.y,2)
0078         error('### The value (y) of data must be a square matrix.')
0079       else
0080         %disp('* Eigenvalues of cdata object');
0081         if nargout <= 1
0082           [h, vdata] = single_operation(d, 'eig',pl);
0083         elseif nargout == 2
0084           [h, vdata, ddata] = single_operation(d, 'eig',pl);
0085         end
0086         %create analysis object(s)
0087         h = set(h, 'inhists', [a.hist]);
0088 
0089         %% Set the var_name to the history
0090         h = set(h, 'invars', cellstr(invars{j}));
0091 
0092         v = ao(vdata, h);
0093         v = setnh(v, 'name',  sprintf('v_eig(%s)', char(invars{j})));
0094         V = [V v];
0095         if ~isempty(ddata)
0096           d = ao(ddata, h);
0097           d = setnh(d, 'name',  sprintf('d_eig(%s)', char(invars{j})));
0098           D = [D d];
0099         end
0100       end
0101     case {'tsdata','fsdata','xydata'}
0102       error('### this function works for cdata type AO only')
0103     otherwise
0104       error('### unknown data type.')
0105   end
0106 end
0107 
0108 % Reshape the ouput to the same size of the input
0109 V = reshape(V, size(as));
0110 varargout{1} = V;
0111 
0112 if nargout > 1
0113   % Reshape the ouput to the same size of the input
0114   D = reshape(D, size(as));
0115   varargout{2} = D;
0116   if nargout > 2
0117     error('### wrong number of outputs')
0118   end
0119 end
0120 
0121 %% Get default params
0122 function plo = getDefaultPL()
0123 
0124 plo = plist();
0125 plo = append(plo, 'option', '');
0126 
0127 % END

Generated on Tue 22-Jan-2008 10:39:13 by m2html © 2003