PCG and MINRES question

Hi, I have a problem which PCG and minres seem to be built to handle, i.e. I have
A(x) = b,
Where A is a function I've written in a .m file (linear) and b is a known column vector (measurement). I am looking for a least squares solution for x, but I have a question. First, how does MATLAB know what the size of x should be? I know what size it should be in reality, but I don't see if there's a way to set it. My function will happily take any size of x and calculate a column vector, but there is a particular size I am looking for.
Second, none of these methods seem to converge (one spits out a bunch of NaNs, the other spits out a bunch of 0s). Does anyone know wat may be causing this problem or have any suggestions? Thanks very much

回答 (2 件)

Walter Roberson
Walter Roberson 2011 年 9 月 30 日

0 投票

To answer your first question: x must be size(A,2) by size(b,1)
Josh Meyer
Josh Meyer 2019 年 9 月 23 日
編集済み: Josh Meyer 2019 年 9 月 23 日

0 投票

Since A*x = b, the sizes of the variables must be:
A * x = b
(M-by-N) * (N-by-1) = (M-by-1)
But since almost all of the iterative solvers only work on square coefficient matrices it is generally the case that N = M. The only solver where this can be ambiguous is LSQR since it calculates a least squares solution for rectangular coefficient matrices. In that case MATLAB can figure out the size of x if you provide an initial guess x0 or a preconditioner matrix M. Failing that, LSQR uses the fact that x must have length equal to that of A'*b.
As for convergence, if you're having trouble getting the iterative methods to converge the answer is usually to use a better preconditioner matrix (which can also be supplied as a function handle). However, if you're looking for a least squares solution to a rectangular system then the problem could be that you're using PCG and not LSQR.

カテゴリ

ヘルプ センター および File ExchangeProgramming についてさらに検索

質問済み:

2011 年 9 月 30 日

編集済み:

2019 年 9 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by