Mercurial > hg > ltpda
comparison m-toolbox/classes/@smodel/inv.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 % INV evaluates the inverse of smodel objects. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: INV evaluates the inverse of smodel objects | |
5 % | |
6 % CALL: mdl = inv(mdl) | |
7 % | |
8 % <a href="matlab:utils.helper.displayMethodInfo('smodel', 'inv')">Parameters Description</a> | |
9 % | |
10 % VERSION: $Id: inv.m,v 1.9 2011/04/08 08:56:30 hewitson Exp $ | |
11 % | |
12 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
13 | |
14 function varargout = inv(varargin) | |
15 | |
16 % Settings | |
17 operatorName = 'inv'; | |
18 | |
19 % Check if this is a call for parameters | |
20 if utils.helper.isinfocall(varargin{:}) | |
21 varargout{1} = getInfo(varargin{3}); | |
22 return | |
23 end | |
24 | |
25 % Check if the method was called by another method | |
26 callerIsMethod = utils.helper.callerIsMethod; | |
27 | |
28 % Collect input variable names | |
29 in_names = cell(size(varargin)); | |
30 for ii = 1:nargin,in_names{ii} = inputname(ii);end | |
31 | |
32 % Collect all smodels and plists | |
33 [as, smodel_invars, rest] = utils.helper.collect_objects(varargin(:), 'smodel', in_names); | |
34 pl = utils.helper.collect_objects(varargin(:), 'plist'); | |
35 | |
36 % Decide on a deep copy or a modify | |
37 mdls = copy(as, nargout); | |
38 | |
39 % Combine plists | |
40 pl = parse(pl, getDefaultPlist()); | |
41 | |
42 % Apply the operator | |
43 mdls.op(operatorName); | |
44 | |
45 if ~callerIsMethod | |
46 % Add history | |
47 mdls.addHistory(getInfo('None'), pl, smodel_invars, [mdls(:).hist]); | |
48 | |
49 % Set name | |
50 mdls.name = [operatorName '(' mdls.name ')']; | |
51 end | |
52 | |
53 % Set output | |
54 varargout{1} = mdls; | |
55 | |
56 end | |
57 | |
58 %-------------------------------------------------------------------------- | |
59 % Get Info Object | |
60 %-------------------------------------------------------------------------- | |
61 function ii = getInfo(varargin) | |
62 | |
63 if nargin == 1 && strcmpi(varargin{1}, 'None') | |
64 sets = {}; | |
65 pls = []; | |
66 else | |
67 sets = {'Default'}; | |
68 pls = getDefaultPlist(); | |
69 end | |
70 % Build info object | |
71 ii = minfo(mfilename, 'smodel', 'ltpda', utils.const.categories.op, '$Id: inv.m,v 1.9 2011/04/08 08:56:30 hewitson Exp $', sets, pls); | |
72 ii.setArgsmin(1); | |
73 end | |
74 | |
75 %-------------------------------------------------------------------------- | |
76 % Get Default Plist | |
77 %-------------------------------------------------------------------------- | |
78 function plout = getDefaultPlist() | |
79 persistent pl; | |
80 if ~exist('pl', 'var') || isempty(pl) | |
81 pl = buildplist(); | |
82 end | |
83 plout = pl; | |
84 end | |
85 | |
86 function pl = buildplist() | |
87 pl = plist.EMPTY_PLIST; | |
88 end |