Home > classes > @ao > det.m

det

PURPOSE ^

DET overloads the determinant function for Analysis objects.

SYNOPSIS ^

function varargout = det(varargin)

DESCRIPTION ^

 DET overloads the determinant function for Analysis objects.

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

 DESCRIPTION: DET overloads the determinant function for Analysis objects.

 CALL:        a = det(a1)   % only with data = cdata

 VERSION:     $Id: det.m,v 1.10 2007/09/27 09:03:25 ingo Exp $

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

 >> pl = det(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 = det(varargin)
0002 % DET overloads the determinant function for Analysis objects.
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: DET overloads the determinant function for Analysis objects.
0007 %
0008 % CALL:        a = det(a1)   % only with data = cdata
0009 %
0010 % VERSION:     $Id: det.m,v 1.10 2007/09/27 09:03:25 ingo Exp $
0011 %
0012 % The following call returns a parameter list object that contains the
0013 % default parameter values:
0014 %
0015 % >> pl = det(ao, 'Params')
0016 %
0017 % HISTORY: 08-05-07 A Monsky
0018 %             Creation
0019 %
0020 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0021 
0022 VERSION  = '$Id: det.m,v 1.10 2007/09/27 09:03:25 ingo Exp $';
0023 
0024 %% Check if this is a call for parameters
0025 if nargin == 2
0026   if isa(varargin{1}, 'ao') && ischar(varargin{2})
0027     in = char(varargin{2});
0028     if strcmp(in, 'Params')
0029       varargout{1} = getDefaultPL();
0030       return
0031     elseif strcmp(in, 'Version')
0032       varargout{1} = VERSION;
0033       return
0034     end
0035   end
0036 end
0037 
0038 %% capture input variable names
0039 invars = {};
0040 
0041 as = [];
0042 bs = [];
0043 ps = [];
0044 
0045 for j=1:nargin
0046   invars = [invars cellstr(inputname(j))];
0047   if isa(varargin{j}, 'ao')
0048     as = [as varargin{j}];
0049   end
0050   if isa(varargin{j}, 'plist')
0051     ps = [ps varargin{j}];
0052   end
0053 end
0054 
0055 
0056 % check plist
0057 if isempty(ps)
0058   pl = getDefaultPL();
0059 else
0060   pl = combine(ps, getDefaultPL);
0061 end
0062 
0063 %% go through analysis objects
0064 for j=1:numel(as)
0065   a = as(j);
0066 
0067   d = get(a, 'data');
0068   dinfo = whos('d');
0069   % Which data type do we have
0070   dtype = dinfo.class;
0071 
0072   switch dtype
0073     case 'cdata'
0074       disp('* DETERMINANT of cdata object');
0075       % make a new cdata object
0076 
0077       if size(d.vals,1) == size(d.vals,2)
0078         [h, c] = single_operation(d, 'det', pl);
0079       else
0080         error('### The value (vals) of data must be a square matrix.')
0081       end
0082 
0083       % make output analysis object
0084       h = set(h, 'inhists', [a.hist]);
0085 
0086       %% Set the var_name to the history
0087       if (j <= nargin)
0088         if (isempty (inputname(j)))
0089           h = set(h, 'invars', cellstr('no var_name'));
0090         else
0091           h = set(h, 'invars', cellstr(inputname(j)));
0092         end
0093       else
0094         h = set(h, 'invars', cellstr('no var_name'));
0095       end
0096 
0097       b = ao(c, h);
0098       b = set(b, 'name',  sprintf('det(%s)', char(invars{1})));
0099     case {'tsdata','fsdata','xydata'}
0100       error('### this function works for cdata type AO only')
0101     otherwise
0102       error('### unknown data type.')
0103   end
0104 
0105   % add to output
0106   bs = [bs b];
0107 end
0108 
0109 bs = reshape(bs, size(as));
0110 varargout{1} = bs;
0111 
0112 %% Get default params
0113 function plo = getDefaultPL()
0114 
0115 plo = plist();
0116 
0117 
0118 % END

Generated on Thu 01-Nov-2007 09:42:34 by m2html © 2003