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