Mercurial > repos > public > sbplib
comparison +blockmatrix/fromMatrix.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 | 3974dccff55b |
children |
comparison
equal
deleted
inserted
replaced
831:d0934d1143b7 | 832:5573913a0949 |
---|---|
1 function bm = fromMatrix(A, div) | |
2 d1 = div{1}; | |
3 d2 = div{2}; | |
4 [n, m] = size(A); | |
5 if n ~= sum(d1) || m ~= sum(d2) | |
6 error('blockmatrix:fromMatrix:NonMatchingDim','The dimensions in div does not sum to the dimensions in A.'); | |
7 end | |
8 | |
9 bm = cell(length(d1), length(d2)); | |
10 I = 1; | |
11 for i = 1:length(d1) | |
12 J = 1; | |
13 for j = 1:length(d2) | |
14 Asub = A(I:(I + d1(i)-1), J:(J + d2(j)-1)); | |
15 if nnz(Asub) == 0 | |
16 bm{i,j} = sparse(d1(i), d2(j)); | |
17 else | |
18 bm{i,j} = Asub; | |
19 end | |
20 J = J + d2(j); | |
21 end | |
22 I = I + d1(i); | |
23 end | |
24 end |