0001 function varargout = inv(varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 VERSION = '$Id: inv.m,v 1.10 2007/09/27 09:03:25 ingo Exp $';
0023
0024
0025
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
0040 invars = {};
0041
0042 as = [];
0043 bs = [];
0044 ps = [];
0045
0046 for j=1:nargin
0047 invars = [invars cellstr(inputname(j))];
0048 if isa(varargin{j}, 'ao')
0049 as = [as varargin{j}];
0050 end
0051 if isa(varargin{j}, 'plist')
0052 ps = [ps varargin{j}];
0053 end
0054 end
0055
0056
0057
0058
0059 if isempty(ps)
0060 pl = getDefaultPL();
0061 else
0062 pl = combine(ps, getDefaultPL);
0063 end
0064
0065
0066 for j=1:numel(as)
0067 a = as(j);
0068 d = get(a, 'data');
0069 dinfo = whos('d');
0070
0071
0072 dtype = dinfo.class;
0073 switch dtype
0074 case 'cdata'
0075 if size(d.vals,1) ~= size(d.vals,2)
0076 error('### The value (vals) of data must be a square matrix.')
0077 else
0078 disp('* INVERSE of cdata object');
0079
0080
0081 [h, c] = single_operation(d, 'inv', pl);
0082
0083
0084 h = set(h, 'inhists', [a.hist]);
0085
0086
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('inv(%s)', char(invars{1})));
0099 end
0100
0101 case {'tsdata','fsdata','xydata'}
0102 error('### this function works for cdata type AO only')
0103 otherwise
0104 error('### unknown data type.')
0105
0106 end
0107
0108
0109 bs = [bs b];
0110 end
0111
0112
0113 bs = reshape(bs, size(as));
0114 varargout{1} = bs;
0115
0116
0117 function plo = getDefaultPL()
0118
0119 plo = plist();
0120
0121