# SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.algebra.linear.matrix.doubles.matrixtype.sparse.solver.iterative.stationary

## Class GaussSeidelSolver

• java.lang.Object
• com.numericalmethod.suanshu.algebra.linear.matrix.doubles.matrixtype.sparse.solver.iterative.stationary.GaussSeidelSolver
• All Implemented Interfaces:
IterativeLinearSystemSolver

public class GaussSeidelSolver
extends Object
implements IterativeLinearSystemSolver
Similar to the Jacobi method, the Gauss-Seidel method (GS) solves each equation in sequential order. However, in each iteration, GS uses the previously computed x components as soon as they are available. In general, GS converges faster than the Jacobi method does (if there is a convergence), though still slowly.

This implementation does not support preconditioning.

Wikipedia: Gauss-Seidel method

• ### Nested classes/interfaces inherited from interface com.numericalmethod.suanshu.algebra.linear.matrix.doubles.matrixtype.sparse.solver.iterative.IterativeLinearSystemSolver

IterativeLinearSystemSolver.Solution
• ### Constructor Summary

Constructors
Constructor and Description
GaussSeidelSolver(int maxIteration, Tolerance tolerance)
Construct a Gauss-Seidel (GS) solver.
• ### Method Summary

All Methods
Modifier and Type Method and Description
IterativeLinearSystemSolver.Solution solve(LSProblem problem)
IterativeLinearSystemSolver.Solution solve(LSProblem problem, IterationMonitor<Vector> monitor)
Solves iteratively Ax = b until the solution converges, i.e., the norm of residual (b - Ax) is less than or equal to the threshold.
• ### Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
• ### Constructor Detail

• #### GaussSeidelSolver

public GaussSeidelSolver(int maxIteration,
Tolerance tolerance)
Construct a Gauss-Seidel (GS) solver.
Parameters:
maxIteration - the maximum number of iterations
tolerance - the convergence threshold
• ### Method Detail

• #### solve

public IterativeLinearSystemSolver.Solution solve(LSProblem problem)
throws ConvergenceFailure
Throws:
ConvergenceFailure
• #### solve

public IterativeLinearSystemSolver.Solution solve(LSProblem problem,
IterationMonitor<Vector> monitor)
throws ConvergenceFailure
Description copied from interface: IterativeLinearSystemSolver
Solves iteratively
Ax = b
until the solution converges, i.e., the norm of residual (b - Ax) is less than or equal to the threshold.
Specified by:
solve in interface IterativeLinearSystemSolver
Parameters:
problem - a system of linear equations
monitor - an iteration monitor
Returns:
an (approximate) solution to the linear problem
Throws:
ConvergenceFailure - if the algorithm fails to converge