comparison m-toolbox/classes/@matrix/transpose.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 % TRANSPOSE implements transpose operator for matrix objects.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: transpose implements transpose operator for a matrix object.
5 %
6 % CALL: obj = obj.';
7 % obj = transpose(obj);
8 %
9 % <a href="matlab:utils.helper.displayMethodInfo('matrix', 'transpose')">Parameters Description</a>
10 %
11 % VERSION: $Id: transpose.m,v 1.11 2011/04/08 08:56:31 hewitson Exp $
12 %
13 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14
15 function varargout = transpose(varargin)
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 matrices 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 % Combine plists
34 usepl = parse(pl, getDefaultPlist());
35
36 % decide to do a deep copy
37 bs = copy(as,nargout);
38
39 % run over input objects
40 for jj =1:numel(bs)
41 % dimension of the elements
42 s1 = size(bs(jj).objs,1);
43 s2 = size(bs(jj).objs,2);
44
45 trp = bs(jj).objs.initObjectWithSize(s2,s1);
46 for ii=1:s1
47 for kk=1:s2
48 trp(kk,ii) = bs(jj).objs(ii,kk);
49 end
50 end
51 bs(jj).objs = trp;
52
53 % set Name
54 bs(jj).name = sprintf('transpose(%s)',as(jj).name);
55 % add history
56 bs(jj).addHistory(getInfo('None'), usepl, matrix_invars(jj), as(jj).hist);
57 end
58 varargout{1} = bs;
59
60
61 end
62
63 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
64 % Local Functions %
65 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
66
67 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
68 %
69 % FUNCTION: getInfo
70 %
71 % DESCRIPTION: Get Info Object
72 %
73 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
74
75 function ii = getInfo(varargin)
76
77 if nargin == 1 && strcmpi(varargin{1}, 'None')
78 sets = {};
79 pls = [];
80 else
81 sets = {'Default'};
82 pls = getDefaultPlist;
83 end
84 % Build info object
85 ii = minfo(mfilename, 'matrix', 'ltpda', utils.const.categories.aop, '$Id: transpose.m,v 1.11 2011/04/08 08:56:31 hewitson Exp $', sets, pls);
86
87 end
88
89 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
90 %
91 % FUNCTION: getDefaultPlist
92 %
93 % DESCRIPTION: Get Default Plist
94 %
95 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
96
97 function plout = getDefaultPlist()
98 persistent pl;
99 if exist('pl', 'var')==0 || isempty(pl)
100 pl = buildplist();
101 end
102 plout = pl;
103 end
104
105 function pl = buildplist()
106 pl = plist.EMPTY_PLIST;
107 end