comparison +blockmatrix/isBlockmatrix.m @ 832:5573913a0949 feature/burgers1d

Merged with default, and updated +scheme/Burgers1D accordingly
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Tue, 11 Sep 2018 15:58:35 +0200
parents a5f1b0267dba
children
comparison
equal deleted inserted replaced
831:d0934d1143b7 832:5573913a0949
1 function b = isBlockmatrix(bm)
2 if ~iscell(bm)
3 b = false;
4 return
5 end
6
7 % Make sure all blocks are numerical matrices
8 for i = 1:length(bm)
9 if ~isnumeric(bm{i})
10 b = false;
11 return
12 end
13 end
14
15 [N,M] = size(bm);
16 % Make sure column dimensions agree
17 for i = 1:N
18 d = [];
19 for j = 1:M
20 d_ij = size(bm{i,j},1);
21 if d_ij == 0
22 continue
23 end
24
25 if isempty(d)
26 d = d_ij;
27 continue
28 end
29
30 if d ~= d_ij
31 b = false;
32 return
33 end
34 end
35 end
36
37 % Make sure row dimensions agree
38 for j = 1:M
39 d = [];
40 for i = 1:N
41 d_ij = size(bm{i,j},2);
42 if d_ij == 0
43 continue
44 end
45
46 if isempty(d)
47 d = d_ij;
48 continue
49 end
50
51 if d ~= d_ij
52 b = false;
53 return
54 end
55 end
56 end
57
58 b = true;
59 end