フィルターのクリア

mrdivide for sparse blockdiagonal matrices

2 ビュー (過去 30 日間)
Frank
Frank 2011 年 9 月 2 日
when computing A/B where A and B are sparse block diagonal and have the same block structure, does it matter in terms of computation time whether to:
1. construct A and B as sparse matrices, and then compute C=A/B 2. for each block i, compute C_i=A_i/B_i, store them in a cell Ccell, and then define C=blkdiag(Ccell{:})

回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2011 年 9 月 3 日
I don't know. You could write a test to find out. From the code below, it seems that as N grows, approach 2 is faster.
N=20;
a=cell(N,1);
b=cell(N,1);
for k=1:N
a{k}=rand(k);
b{k}=rand(k);
end
t1=0;t2=0;
for k=1:100
tic;
A=blkdiag(a{:});
B=blkdiag(b{:});
C=A/B;
t1=t1+toc;
tic;
d=cell(N,1);
for j=1:N
d{j}=a{j}/b{j};
end
D=blkdiag(d{:});
t2=t2+toc;
end
fprintf('time for approach 1: %f\n',t1);
fprintf('time for approach 2: %f\n',t2);
time for approach 1: 0.503683
time for approach 2: 0.129935

カテゴリ

Help Center および File ExchangeLanguage Fundamentals についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by