Sparse and nonspare QR
古いコメントを表示
I have question regarding the difference between the sparse and non-sparse QR as implimented R2012b. I have a matrix, X, that is mostly zeros which I wish to upper-triangularize. Because the matrix X is formed piecemeal from several sparse multiplications, the X is sparse. The results of:
a1 = qr(X)
and
a2 = triu(qr(full(X)))
are completely different. The few nonzero values end up in very different places. The code is for a square root DWY backward (Fisher type) filter as in Park and Kailath 96. Based on what I know of the problem and what the answer should be, a2 is correct (or at least I know a1 is incorrect because what should be the multiplication of 2 nonzero submatrices is zero in a1 but not a2).
Does anyone know why the two are different? Further is there a way to force qr(X) to produce the same result as triu(qr(full(X))) without resorting to the full() call?
Thank you
採用された回答
その他の回答 (2 件)
James Tursa
2013 年 6 月 5 日
編集済み: James Tursa
2013 年 6 月 5 日
What happens when you compare the complete result, e.g.,
[a1 r1] = qr(X);
[a2 r2] = qr(full(X));
Then compare a1*r1 with a2*r2. There may be some sign ambiguity in the factored results that you cannot control.
Richard Brown
2013 年 6 月 5 日
編集済み: Richard Brown
2013 年 6 月 5 日
On my system they match (up to the signs of the rows, as you'd expect).
m = 20;
n = 10;
X = sprand(m,n,0.3);
Rs = qr(X);
Rs = spdiags(sign(spdiags(Rs, 0)),0,n,n) * Rs(1:n,1:n);
Rf = triu(qr(full(X)));
Rf = diag(sign(diag(Rf))) * Rf(1:n,1:n);
disp(norm(Rf - Rs));
Can you possibly provide a MWE? Is your matrix full rank?
2 件のコメント
Jason
2013 年 6 月 6 日
Richard Brown
2013 年 6 月 7 日
thanks - I didn't get time to get back to this question this week, but try back on Monday sometime!
カテゴリ
ヘルプ センター および File Exchange で Sparse Matrices についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!