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.15 2007/12/24 19:48:38 hewitson 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.15 2007/12/24 19:48:38 hewitson 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.15 2007/12/24 19:48:38 hewitson Exp $';
0023 bs      = [];
0024 
0025 %% Check if this is a call for parameters
0026 if nargin == 2
0027   if isa(varargin{1}, 'ao') && ischar(varargin{2})
0028     in = char(varargin{2});
0029     if strcmp(in, 'Params')
0030       varargout{1} = getDefaultPL();
0031       return
0032     elseif strcmp(in, 'Version')
0033       varargout{1} = VERSION;
0034       return
0035     end
0036   end
0037 end
0038 
0039 %% Collect input ao's, plist's and ao variable names
0040 in_names = {};
0041 for ii = 1:nargin
0042   in_names{end+1} = inputname(ii);
0043 end
0044 
0045 [as, ps, invars] = collect_inputs(varargin, in_names);
0046 
0047 % check plist
0048 if isempty(ps)
0049   pl = getDefaultPL();
0050 else
0051   pl = combine(ps, getDefaultPL);
0052 end
0053 
0054 %% go through analysis objects
0055 for j=1:numel(as)
0056   a = as(j);
0057 
0058   d = get(a, 'data');
0059   dinfo = whos('d');
0060   % Which data type do we have
0061   dtype = dinfo.class;
0062 
0063   switch dtype
0064     case 'cdata'
0065       % make a new cdata object
0066 
0067       if size(d.y,1) == size(d.y,2)
0068         [h, c] = single_operation(d, 'det', pl);
0069       else
0070         error('### The value (y) of data must be a square matrix.')
0071       end
0072 
0073       % make output analysis object
0074       h = set(h, 'inhists', [a.hist]);
0075 
0076       %% Set the var_name to the history
0077       h = set(h, 'invars', cellstr(invars{j}));
0078 
0079       b = ao(c, h);
0080       b = setnh(b, 'name',  sprintf('det(%s)', char(invars{j})));
0081     case {'tsdata','fsdata','xydata'}
0082       error('### this function works for cdata type AO only')
0083     otherwise
0084       error('### unknown data type.')
0085   end
0086 
0087   % add to output
0088   bs = [bs b];
0089 end
0090 
0091 bs = reshape(bs, size(as));
0092 varargout{1} = bs;
0093 
0094 %% Get default params
0095 function plo = getDefaultPL()
0096 
0097 plo = plist();
0098 
0099 
0100 % END

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