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.html,v 1.14 2008/03/31 10:27:33 hewitson Exp $

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

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

 The following call returns a string that contains the routine CVS version:

 >> version = det(ao,'Version')

 The following call returns a string that contains the routine category:

 >> category = det(ao,'Category')

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

Generated on Mon 31-Mar-2008 12:20:24 by m2html © 2003