Class GaussSeidelSolver
- java.lang.Object
-
- dev.nm.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.- See Also:
- Wikipedia: Gauss-Seidel method
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface dev.nm.algebra.linear.matrix.doubles.matrixtype.sparse.solver.iterative.IterativeLinearSystemSolver
IterativeLinearSystemSolver.Solution
-
-
Constructor Summary
Constructors Constructor Description GaussSeidelSolver(int maxIteration, Tolerance tolerance)
Construct a Gauss-Seidel (GS) solver.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.
-
-
-
Constructor Detail
-
GaussSeidelSolver
public GaussSeidelSolver(int maxIteration, Tolerance tolerance)
Construct a Gauss-Seidel (GS) solver.- Parameters:
maxIteration
- the maximum number of iterationstolerance
- 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 iterativelyAx = 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 interfaceIterativeLinearSystemSolver
- Parameters:
problem
- a system of linear equationsmonitor
- an iteration monitor- Returns:
- an (approximate) solution to the linear problem
- Throws:
ConvergenceFailure
- if the algorithm fails to converge
-
-