## Solving linear equation with Gauss-Seidel method gives wrong results

Question

Using R package optR for solving linear equation gives incorrect results for gauss-seidel method. I tried solving with different methods and it looks ok. For instance solve or using optR but with method gauss. Example is here. Or am I doing something wrong?

library(optR)
A<-matrix(c(5,-1,2, 3, 8,-2,1, 1,4), nrow=3,ncol=3, byrow = TRUE)
b<-matrix(c(12,-25,6), nrow=3,ncol=1,byrow=TRUE)

Z1<-optR(A, b,method="gaussseidel", iter=500, tol=1e-7)
Z2 <-optR(A, b, method="gauss", iter=500, tol=1e-7)
Z3 <- solve(A,b)

print(Z1)
print(Z2)
print(Z3)

A %*% Z1\$beta - b
A %*% Z2\$beta - b
A %*% Z3 - b

Coefficients for Z1 are incorrect:

> print(Z1)
call:
optR.default(x = A, y = b, method = "gaussseidel", iter = 500,
tol = 1e-07)

Coefficients:
[,1]
[1,]  4.183908
[2,] -2.379310
[3,] -1.781609
> print(Z2)
call:
optR.default(x = A, y = b, method = "gauss", iter = 500, tol = 1e-07)

Coefficients:
[,1]
[1,]    1
[2,]   -3
[3,]    2
> print(Z3)
[,1]
[1,]    1
[2,]   -3
[3,]    2
>
> A %*% Z1\$beta - b
[,1]
[1,]   7.735632
[2,]  22.080460
[3,] -11.321839
> A %*% Z2\$beta - b
[,1]
[1,]  0.000000e+00
[2,] -3.552714e-15
[3,]  0.000000e+00
> A %*% Z3 - b
[,1]
[1,]  0.000000e+00
[2,] -3.552714e-15
[3,]  0.000000e+00