Mercurial > repos > public > sbplib
comparison +blockmatrix/isBlockmatrix.m @ 886:8894e9c49e40 feature/timesteppers
Merge with default for latest changes
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Thu, 15 Nov 2018 16:36:21 -0800 |
parents | a5f1b0267dba |
children |
comparison
equal
deleted
inserted
replaced
816:b5e5b195da1e | 886:8894e9c49e40 |
---|---|
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 |