comparison m-toolbox/classes/@matrix/fromInput.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children bc767aaa99a8
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1 % Construct a matrix object from ltpda_uoh objects.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % FUNCTION: fromInput
5 %
6 % DESCRIPTION: Construct a matrix object from ltpda_uoh objects.
7 %
8 % CALL: matrix = matrix.fromInput(inobjs)
9 %
10 % VERSION: $Id: fromInput.m,v 1.9 2011/02/14 13:20:24 ingo Exp $
11 %
12 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13 function obj = fromInput(obj, pli, callerIsMethod)
14
15 import utils.const.*
16
17 if callerIsMethod
18 % do nothing
19 pl = pli;
20 else
21 utils.helper.msg(msg.OPROC1, 'Construct from inputs');
22 pl = combine(pli, matrix.getDefaultPlist('From Input'));
23 end
24 shape = pl.find('shape');
25 objs = pl.find('objs');
26
27 if iscell(objs)
28 [inobjs, ao_invars, rest] = utils.helper.collect_objects(objs(:), '');
29 if ~isempty(rest)
30 warning('LTPDA:MATRIX', '### The matrix constructor collects only all %s-objects but there are some %s-objects left.', class(inobjs), class(rest{1}));
31 end
32 else
33 inobjs = objs;
34 end
35
36 if ~isempty(shape)
37 obj.objs = reshape(inobjs, shape);
38 else
39 obj.objs = inobjs;
40 end
41
42
43 if callerIsMethod
44 % do less
45 else
46 pl.pset('shape', size(obj.objs));
47 % Remove the input objects from the plist because we add the histories of
48 % the input objects to the matrix object.
49 pl.remove('objs');
50
51 inhists = [];
52 if ~isempty(inobjs)
53 inhists = [inobjs(:).hist];
54 end
55 obj.addHistory(matrix.getInfo('matrix', 'None'), pl, [], inhists);
56 warning('off', utils.const.warnings.METHOD_NOT_FOUND);
57 % remove parameters we already used
58 pl_set = copy(pl,1);
59 if pl_set.isparam('objs')
60 pl_set.remove('objs');
61 end
62 if pl_set.isparam('shape')
63 pl_set.remove('shape');
64 end
65 obj.setProperties(pl_set);
66 warning('on', utils.const.warnings.METHOD_NOT_FOUND);
67 end
68
69 end