Home > classes > @ao > svd.m

svd

PURPOSE ^

SVD overloads the determinant function for Analysis objects.

SYNOPSIS ^

function varargout = svd(varargin)

DESCRIPTION ^

 SVD overloads the determinant function for Analysis objects.

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

 DESCRIPTION: SVD overloads the determinant function for Analysis objects.

 CALL:        u        = svd (a,pl)
             [u, s]    = svd (a,pl)
             [u, s, v] = svd (a,pl)
             [u, s, v] = svd (a)

 INPUTS:      a    - input analysis object
              pl   - a parameter list

 OTPUTS:      like matlab fct

 PARAMETERS:  'option' - a string or value that can be submited  i.e. 'econ'
                         to produve economy size decomposition
                       - options are the same as for the matlab function

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

              >> pl = svd(ao, 'Params')

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

 HISTORY:     08-05-07A Monsky
                Creation.

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

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

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