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.8 2007/07/12 15:56:44 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.8 2007/07/12 15:56:44 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.8 2007/07/12 15:56:44 ingo Exp $';
0049 
0050 as = [];
0051 pl = [];
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     pl = [pl varargin{j}];
0063   end
0064 end
0065 
0066 % check plist
0067 if ~isempty (pl)
0068   pl = combine(pl);
0069 end
0070 
0071 % Check input analysis object
0072 for j=1:length(as)
0073   a = as(j);
0074 
0075   d = get(a, 'data');
0076   dinfo = whos('d');
0077 
0078   % Which data type do we have
0079   dtype = dinfo.class;
0080 
0081   udata = [];
0082   sdata = [];
0083   vdata = [];
0084 
0085   switch dtype
0086      case 'cdata'
0087        disp('* DETERMINANT of cdata object');
0088        if nargout <= 1
0089          [h, udata] = single_operation(a.data, 'svd',pl);
0090        elseif nargout == 2
0091          [h, udata, sdata] = single_operation(a.data, 'svd',pl);
0092        elseif nargout == 3
0093          [h, udata, sdata, vdata] = single_operation(a.data, 'svd',pl);
0094        end
0095        %create analysis object(s)
0096        h = set(h, 'invars', [a.hist]);
0097        u = ao(udata, h);
0098        u = set(u, 'name',  sprintf('u_svd(%s)', char(invars{1})));
0099        U = [U u];
0100        if ~isempty(sdata)
0101            s = ao(sdata, h);
0102            s = set(s, 'name',  sprintf('s_svd(%s)', char(invars{1})));
0103            S = [S s];
0104        end
0105        if ~isempty(vdata)
0106            v = ao(vdata, h);
0107            v = set(v, 'name',  sprintf('v_svd(%s)', char(invars{1})));
0108            V = [V v];
0109        end
0110 
0111      case {'tsdata','fsdata','xydata'}
0112        error('### this function works for cdata type AO only')
0113      otherwise
0114        error('### unknown data type.')
0115   end
0116 
0117 end
0118 
0119 varargout{1} = U;
0120 if nargout > 1
0121     varargout{2} = S;
0122     if nargout > 2
0123         varargout{3} = V;
0124         if nargout > 3
0125             error('### wrong number of outputs')
0126         end
0127     end
0128 end
0129 
0130 %% Get default params
0131 function plo = getDefaultPL()
0132 
0133 disp('* creating default plist...');
0134 plo = plist();
0135 plo = append(plo, 'option', []);
0136 disp('* done.');
0137 
0138 
0139 % END

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