I'm guessing that, to within the letters you choose to use for them, your matrix M is
15 -3 -1
-3 18 -6
-4 -1 12 |
and that your RHS vector b is
so that your matrix equation is
So your equations FOR THESE SPECIFIC NUMBERS (and please read the comment about the start of array indices further down this post) are
15 C[1] - 3 C[2] - C[3] = 3800
-3 C[1] + 18 C[2] - 6 C[3] = 1200
-4 C[1] - C[2] + 12 C[3] = 2350 |
Rearrange to make each diagonal element the subject:
C[1] = ( 3800 + 3 C[2] + C[3] ) / 15
C[2] = ( 1200 + 3 C[1] + 6 C[3] ) / 18
C[3] = ( 2350 + 4 C[1] + C[2] ) / 12 |
Gauss-Seidel just keeps looping through these equations until the maximum change in a loop is less than some small tolerance. Looking at how diagonally-dominant your matrix is, it should converge in no time.
These numbers will help you see what is going on, but you should code it in such a way that:
(1) You can use any numbers in the matrix or RHS (at least those for which G-S converges)
(2) Ideally you should have any number of elements (not just 3)
As an additional warning, you should also be aware that array indices in C++ start from 0, not 1.
If you show some code there are lots of people on this forum who will help you to improve / correct it, but the onus is on you to write some code first.