PCG and MINRES question

4 ビュー (過去 30 日間)
Karl 2011 年 9 月 30 日
編集済み: Josh Meyer 2019 年 9 月 23 日
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 日
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 日
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.

Community Treasure Hunt

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

Start Hunting!

Translated by