-2

I need to understand a part of the GMRES algorithm written in these languages. What makes me a problem is the following piece:

y = H(1:k,1:k) \ beta(1:k);
x = x + Q(:,1:k)*y; 

Can someone explain what does it mean in extended form.

Thank you in advance.

yarchik
  • 336
  • 1
  • 8
  • 2
    Please, see [How to handle “Explain how this ${code dump} works” questions](https://meta.stackoverflow.com/a/253896/2988) over on [meta]. – Jörg W Mittag Nov 12 '17 at 17:27
  • 1
    @JörgWMittag Such a hostile attitude... I posted a concise question, and got a quick answer. Isn't it the purpose of SO? But I would be extremely interested to know how one can formulate the question without including this two lines of code? Bad day ? – yarchik Nov 12 '17 at 17:33
  • 1
    It's the new SO manner since quite long time. Every question is a duplicate or something or is just out of place. Apparently, it's getting closer to a structured FAQ archive than to a website in which people receive help by asking questions. – Tommaso Belluzzo Nov 12 '17 at 18:13
  • @TommasoBelluzzo alas, that's exactly the intent of SO. I sympathise with yarchik, but the problem is SO isn't a problem-solving service, but a repository for exchange of information, one which ideally should be searchable and useful to future visitors. Yarchik: I'm glad you solved your problem, if you would like to help future users, please kindly edit your title to make it more useful for people having the exact same problem (e.g. "GMRES algorithm in matlab" or "matlab backslash operator"). In fact, when you do, I suspect SO will suggest similar questions where this was discussed previously. – Tasos Papastylianou Nov 13 '17 at 10:47

1 Answers1

1

For what concerns the first equation:

H(1:k,1:k) = sub-matrix of matrix H that you obtain by taking rows from 1 (beginning) to k and columns from 1 (beginning) to k
beta(1:k) = sub-vector of vector beta that you obtain by taking elements from 1 (beginning) to k
y = is a matrix obtained by solving a symbolic matrix left division between sub-matrix of H and the sub-vector of beta

For what concerns the second equation:

Q(:,1:k) = sub-matrix of matrix Q with all the rows and columns from 1 (beginning) to k
x = a matrix that is obtained by adding to it's previous value the result of the multiplication between the sub-matrix of matrix Q and y

Indexing in Matlab is 1-based, not 0-based. So index 1 corresponds to the first element of whatever you are working with. Example of sub-matrix by indexing:

A = [
  2 3 4;
  1 2 3;
  3 4 4
];

B = A(1:2,1:2);

B is then equal to:

[
  2 3;
  1 2
];

C = A(:,1:2);

C is then equal to:

[
  2 3;
  1 2;
  3 4
];

That weird division symbol represents a matrix left division (for more information: mathworks.com/help/symbolic/mldivide.html): X = A\B solves the symbolic system of linear equations in matrix form: A*X = B for X.

Tommaso Belluzzo
  • 23,232
  • 8
  • 74
  • 98