jsat.linear.solvers
Class ConjugateGradient
- java.lang.Object
-
- jsat.linear.solvers.ConjugateGradient
-
public class ConjugateGradient extends java.lang.ObjectProvides an iterative implementation of the COnjugate Gradient Method.
The Conjugate method, if using exact arithmetic, produces the exact result after a finite number of iterations that is no more then the number of rows in the matrix. Because of this, no max iteration parameter is given.
-
-
Constructor Summary
Constructors Constructor and Description ConjugateGradient()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static Vecsolve(double eps, Matrix A, Vec x, Vec b)Uses the Conjugate Gradient method to solve a linear system of equations involving a symmetric positive definite matrix.
A symmetric positive definite matrix is a matrix A such that:
AT = A xT * A * x > 0 for all x != 0
NOTE: No checks will be performed to confirm these properties of the given matrix.static Vecsolve(double eps, Matrix A, Vec x, Vec b, Matrix Minv)Uses the Conjugate Gradient method to solve a linear system of equations involving a symmetric positive definite matrix.
A symmetric positive definite matrix is a matrix A such that:
AT = A xT * A * x > 0 for all x != 0
NOTE: No checks will be performed to confirm these properties of the given matrix.static Vecsolve(Matrix A, Vec b)static VecsolveCGNR(double eps, Matrix A, Vec x, Vec b)Uses the Conjugate Gradient method to compute the least squares solution to a system of linear equations.
Computes the least squares solution to A x = b.static VecsolveCGNR(Matrix A, Vec b)
-
-
-
Method Detail
-
solve
public static Vec solve(double eps, Matrix A, Vec x, Vec b)
Uses the Conjugate Gradient method to solve a linear system of equations involving a symmetric positive definite matrix.
A symmetric positive definite matrix is a matrix A such that:
- AT = A
- xT * A * x > 0 for all x != 0
NOTE: No checks will be performed to confirm these properties of the given matrix. If a matrix is given that does not meet this requirements, invalid results may be returned.- Parameters:
eps- the precision of the desired result.A- the symmetric positive definite matrixx- an initial guess for x, can be all zeros. This vector will be alteredb- the target values- Returns:
- the approximate solution to the equation A x = b
-
solve
public static Vec solve(double eps, Matrix A, Vec x, Vec b, Matrix Minv)
Uses the Conjugate Gradient method to solve a linear system of equations involving a symmetric positive definite matrix.
A symmetric positive definite matrix is a matrix A such that:
- AT = A
- xT * A * x > 0 for all x != 0
NOTE: No checks will be performed to confirm these properties of the given matrix. If a matrix is given that does not meet this requirements, invalid results may be returned.- Parameters:
eps- the precision of the desired result.A- the symmetric positive definite matrixx- an initial guess for x, can be all zeros. This vector will be alteredb- the target valuesMinv- the of a matric M, such that M is a symmetric positive definite matrix. Is applied as M-1( A x - b = 0) to increase convergence and stability. These increases are soley a property of M-1- Returns:
- the approximate solution to the equation A x = b
-
solveCGNR
public static Vec solveCGNR(double eps, Matrix A, Vec x, Vec b)
Uses the Conjugate Gradient method to compute the least squares solution to a system of linear equations.
Computes the least squares solution to A x = b. Where A is an m x n matrix and b is a vector of length m and x is a vector of length n
NOTE: Unlikesolve(double, jsat.linear.Matrix, jsat.linear.Vec, jsat.linear.Vec), the CGNR method does not need any special properties of the matrix. Because of this, slower convergence or numerical error can occur.- Parameters:
eps- the desired precision for the resultA- any m x n matrixx- the initial guess for x, can be all zeros. This vector will be alteredb- the target values- Returns:
- the least squares solution to A x = b
-
-
DataMelt 3.0 © DataMelt by jWork.ORG