rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
CompositeMatrixDefault.m
1 classdef CompositeMatrixDefault < VecMat.ICompositeMatrix
2  %classdef CompositeMatrixDefault
3  % For block-diagonal matrices
4 
5 
6  %% properties
7 
8 
9  %% methdos
10  methods
11 
12  function obj = CompositeMatrixDefault(length)
13  obj.M = cell(1, length);
14  end
15 
16  function s = size(obj, dim)
17  sizes = cellfun(@(mat)size(mat, dim), obj.M);
18  s = sum(sizes);
19  end
20 
21  function mat = getMatrix(obj)
22  M = cell(1, length(obj));
23  for i = 1:length(M)
24  if isa(obj.M{i}, 'VecMat.ICompositeMatrix')
25  M{i} = getMatrix(obj.M{i});
26  else
27  M{i} = obj.M{i};
28  end
29  end
30  mat = blkdiag(M{:});
31  end
32 
33  function res = copy(this)
34  res = VecMat.CompositeMatrixDefault(this.length);
35  for i = 1:this.length
36  tmp = get(this, i);
37  if isa(tmp, 'handle') && ismethod(tmp, 'copy')
38  res = set(res, copy(tmp), i);
39  else
40  res = set(res, get(this, i), i);
41  end
42  end
43  end
44 
45  end
46 
47 end
Handle class holding a cell array for a "composite-matrix".