Mercurial > repos > public > sbplib
comparison +blockmatrix/toMatrix.m @ 606:c14875cf7ae6 feature/grids
Make blockMatrix.toMatrix faster for large matrices.
author | Martin Almquist <malmquist@stanford.edu> |
---|---|
date | Sat, 14 Oct 2017 22:24:19 -0700 |
parents | 46aa0b6a10cd |
children | b079c437174c |
comparison
equal
deleted
inserted
replaced
604:082c7bf3192e | 606:c14875cf7ae6 |
---|---|
15 n_ind = [0 cumsum(n)]; | 15 n_ind = [0 cumsum(n)]; |
16 m_ind = [0 cumsum(m)]; | 16 m_ind = [0 cumsum(m)]; |
17 | 17 |
18 for i = 1:size(bm,1) | 18 for i = 1:size(bm,1) |
19 for j = 1:size(bm,2) | 19 for j = 1:size(bm,2) |
20 if isempty(bm{i,j}) | 20 if(isempty(bm{i,j})) |
21 continue | 21 bm{i,j} = sparse(n(i),m(j)); |
22 end | 22 end |
23 % TODO: If this ever fails for large matrices. Try cell2mat instead. | |
24 A(n_ind(i)+1:n_ind(i+1),m_ind(j)+1:m_ind(j+1)) = bm{i,j}; | |
25 end | 23 end |
26 end | 24 end |
25 A = cell2mat(bm); | |
27 end | 26 end |