Class SORDecomposition
java.lang.Object
net.finmath.finitedifference.solvers.SORDecomposition
Performs a Successive Over-Relaxation (SOR) decomposition for solving linear
systems
of the form
A x = b.
The input matrix A is decomposed into its diagonal part D,
strictly
lower triangular part L, and strictly upper triangular part
U. The
solver then applies an iterative SOR (Gauss-Seidel with relaxation) sweep to
approximate the solution.
- Author:
- Enrico De Vecchi, Alessandro Gnoatto
-
Constructor Summary
ConstructorsConstructorDescriptionSORDecomposition(org.apache.commons.math3.linear.RealMatrix matrixA) Constructs the decomposition of the given matrixAintoD,L, andU. -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.commons.math3.linear.RealMatrixgetD()Returns the diagonal matrixDof the decomposition.org.apache.commons.math3.linear.RealMatrixgetL()Returns the strictly lower triangular matrixLof the decomposition.org.apache.commons.math3.linear.RealMatrixgetSol(org.apache.commons.math3.linear.RealMatrix x0, org.apache.commons.math3.linear.RealMatrix b, double w, int steps) Performs a fixed number of SOR iterations to approximate the solution ofA x = b.org.apache.commons.math3.linear.RealMatrixgetSol(org.apache.commons.math3.linear.RealMatrix x0, org.apache.commons.math3.linear.RealMatrix b, double w, int maxIters, double tol) Performs SOR (Gauss-Seidel with relaxation) to solveA x = b.org.apache.commons.math3.linear.RealMatrixgetU()Returns the strictly upper triangular matrixUof the decomposition.
-
Constructor Details
-
SORDecomposition
public SORDecomposition(org.apache.commons.math3.linear.RealMatrix matrixA) Constructs the decomposition of the given matrixAintoD,L, andU.- Parameters:
matrixA- The input square matrix to decompose.
-
-
Method Details
-
getD
public org.apache.commons.math3.linear.RealMatrix getD()Returns the diagonal matrixDof the decomposition.- Returns:
- The diagonal part of
A.
-
getL
public org.apache.commons.math3.linear.RealMatrix getL()Returns the strictly lower triangular matrixLof the decomposition.- Returns:
- The strictly lower triangular part of
A.
-
getU
public org.apache.commons.math3.linear.RealMatrix getU()Returns the strictly upper triangular matrixUof the decomposition.- Returns:
- The strictly upper triangular part of
A.
-
getSol
public org.apache.commons.math3.linear.RealMatrix getSol(org.apache.commons.math3.linear.RealMatrix x0, org.apache.commons.math3.linear.RealMatrix b, double w, int steps) Performs a fixed number of SOR iterations to approximate the solution ofA x = b.This method is a backwards-compatible entry point which delegates to
getSol(RealMatrix, RealMatrix, double, int, double)withtol = 0.0.- Parameters:
x0- The initial guess forx(n x 1).b- The right-hand side vectorb(n x 1).w- The relaxation factoromega(typically0 < w < 2).steps- The number of iterations to perform.- Returns:
- The approximate solution after the specified number of iterations.
-
getSol
public org.apache.commons.math3.linear.RealMatrix getSol(org.apache.commons.math3.linear.RealMatrix x0, org.apache.commons.math3.linear.RealMatrix b, double w, int maxIters, double tol) Performs SOR (Gauss-Seidel with relaxation) to solveA x = b.If
tol > 0.0, the iteration stops early when the infinity norm of the residual satisfies||A x - b||_inf <= tol. Iftol == 0.0, the solver always runsmaxItersiterations.- Parameters:
x0- Initial guess (n x 1).b- Right-hand side (n x 1).w- Relaxation factoromega(typically0 < w < 2).maxIters- Maximum number of sweeps.tol- Residual tolerance in infinity norm (set to 0 to disable early stopping).- Returns:
- Approximate solution.
-