PCG and MINRES question
조회 수: 4 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
답변 (2개)
Walter Roberson
2011년 9월 30일
To answer your first question: x must be size(A,2) by size(b,1)
댓글 수: 0
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.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Time Series Objects에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!