The realization of Gauss-Seidel method expressed by Matrix

There are two representations of Gauss-Seidel iterative method in

solving equations, one is in the form of linear equations, and the other is in the form of matrix, which is in the form of

.
x_{0} = 
x_{k+1} = D^{-1}(b-Ux_k-Lx_{k+1})    // 1

I finally can in the form of equations;
but according to the matrix form of formula 1:

x1 = x0;    // x_k
x2;         // x_{k+1}
while(kPP<km && norm2(A*x2-b)>tol){
    x2 = inv(D)*(b-U*x1-L*x2);    // 1
    x1 = x2;
}

but the actual execution result, statement 1 and x2 = inv (D) * (b-U*x1-L*x1); is the same effect,
because when executing the expression after =, x1 and x2 have the same value;
, so is it impossible to write the actual code for formula 1?

CPP
Mar.03,2021
Menu