org.jeometry.math.solver.Solver Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jeometry-api Show documentation
Show all versions of jeometry-api Show documentation
Jeometry, a Mathematic and Geometry library for Java
package org.jeometry.math.solver;
import org.jeometry.Jeometry;
import org.jeometry.math.Matrix;
import org.jeometry.math.Vector;
/**
* This interface describes a linear system solver using matrices.
* Let A a general matrix and B a column matrix with the same number of columns as A.
* Solving a linear system consists in the determination of the matrix X that is such that:
*
* A×X = B
*
* @author Julien Seinturier - COMEX S.A. - [email protected] - https://github.com/jorigin/jeometry
* @version {@value Jeometry#version} b{@value Jeometry#BUILD}
* @since 1.0.0
*/
public interface Solver {
/**
* Identifies a linear solver that uses Gauss elimination.
*/
public static int METHOD_GAUSS = 1;
/**
* Identifies a linear solver that uses LU decomposition.
*/
public static int METHOD_LU = 2;
/**
* Identifies a linear solver that uses QR decomposition.
*/
public static int METHOD_QR = 3;
/**
* Identifies a linear solver that uses Cholesky decomposition.
*/
public static int METHOD_CHOLESKY = 4;
/**
* Return the method used by the solver.
* @return the method used by the solver
* @see #METHOD_GAUSS
* @see #METHOD_LU
* @see #METHOD_QR
*/
public int getMethod();
/**
* Solve the system defined by a×x = b.
* @param a the a matrix that contains the coefficients
* @param b the b matrix that contains the constants
* @return the x matrix that contains the solution or null
if no solution has been found
* @throws IllegalArgumentException if the input matrices cannot lead to a solution (singular, non invertible, ...)
*/
public Matrix solve(Matrix a, Matrix b);
/**
* Solve the system defined by a×x = b.
* @param a the a matrix that contains the coefficients
* @param b the b matrix that contains the constants
* @param x the x matrix that contains the solution
* @return the same reference as x
or null
if no solution has been found
* @throws IllegalArgumentException if the input matrices cannot lead to a solution (singular, non invertible, ...)
*/
public Matrix solve(Matrix a, Matrix b, Matrix x);
/**
* Solve the system defined by a×x = b.
* @param a the a matrix that contains the coefficients
* @param b the b vector that contains the constants
* @return the x vector that contains the solution or null
if no solution has been found
* @throws IllegalArgumentException if the input matrices cannot lead to a solution (singular, non invertible, ...)
*/
public Vector solve(Matrix a, Vector b);
/**
* Solve the system defined by a×x = b.
* @param a the matrix that contains the coefficients
* @param b the vector that contains the constants
* @param x the vector that contains the solution
* @return a reference on x
or null
if no solution has been found
* @throws IllegalArgumentException if the input matrices cannot lead to a solution (singular, non invertible, ...)
*/
public Vector solve(Matrix a, Vector b, Vector x);
}