comparison m-toolbox/classes/@matrix/simplify.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 % SIMPLIFY each model in the matrix.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: SIMPLIFY each model in the matrix.
5 %
6 % CALL: dmod = simplify(imod)
7 %
8 % <a href="matlab:utils.helper.displayMethodInfo('matrix', 'simplify')">Parameters Description</a>
9 %
10 % VERSION: $Id: simplify.m,v 1.6 2011/04/08 08:56:31 hewitson Exp $
11 %
12 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13 function varargout = simplify(varargin)
14
15 % utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename);
16
17 % Check if this is a call for parameters
18 if utils.helper.isinfocall(varargin{:})
19 varargout{1} = getInfo(varargin{3});
20 return
21 end
22
23 % Collect input variable names
24 in_names = cell(size(varargin));
25 for ii = 1:nargin
26 in_names{ii} = inputname(ii);
27 end
28
29 % Collect all smodels and plists
30 [as, matrix_invars, rest] = utils.helper.collect_objects(varargin(:), 'matrix', in_names);
31 [pl, pl_invars, rest] = utils.helper.collect_objects(rest(:), 'plist', in_names);
32
33 % Merge with default plist
34 pl = parse(pl, getDefaultPlist);
35
36 bs = copy(as, nargout);
37
38 % loop over input matrices
39 for ww=1:numel(bs)
40 imod=bs(ww);
41 for ss=1:numel(imod.objs)
42 if strcmpi(class(imod.objs(ss)),'smodel')
43 simplify(imod.objs(ss));
44 end
45 end
46 end
47
48 if nargout == 1
49 varargout{1} = bs;
50 elseif nargout == numel(bs)
51 % List of outputs
52 for ii = 1:numel(bs)
53 varargout{ii} = bs(ii);
54 end
55 end
56
57 end
58
59 %--------------------------------------------------------------------------
60 % Get Info Object
61 %--------------------------------------------------------------------------
62 function ii = getInfo(varargin)
63
64 if nargin == 1 && strcmpi(varargin{1}, 'None')
65 sets = {};
66 pls = [];
67 else
68 sets = {'Default'};
69 pls = getDefaultPlist;
70 end
71 % Build info object
72 ii = minfo(mfilename, 'matrix', 'ltpda', utils.const.categories.op, '$Id: simplify.m,v 1.6 2011/04/08 08:56:31 hewitson Exp $', sets, pls);
73 ii.setModifier(false);
74 end
75
76 %--------------------------------------------------------------------------
77 % Get Default Plist
78 %--------------------------------------------------------------------------
79 function plout = getDefaultPlist()
80 persistent pl;
81 if exist('pl', 'var')==0 || isempty(pl)
82 pl = buildplist();
83 end
84 plout = pl;
85 end
86
87 function pl = buildplist()
88 pl = plist.EMPTY_PLIST;
89 end