Package io.bhagat.math.linearalgebra
Class LinearEquationSolver
- java.lang.Object
-
- io.bhagat.math.linearalgebra.LinearEquationSolver
-
public class LinearEquationSolver extends java.lang.Objecta class to solve linear equations- Author:
- Bhagat
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classLinearEquationSolver.ImproperNumberOfEquationsExceptionAn exception for not giving the same amount of variables and equations
-
Field Summary
Fields Modifier and Type Field Description static intCRAMARS_RULEconstant for Cramar's Rulestatic intGAUSS_METHODconstant for Gauss Methodstatic intINVERSE_METHODconstant for Inverse Method
-
Constructor Summary
Constructors Constructor Description LinearEquationSolver()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.HashMap<java.lang.String,java.lang.Double>cramarsRule(Matrix A, Vector b, java.util.ArrayList<java.lang.String> variables)computes the solutions of the matrix equation Ax=b using cramar's rulestatic java.util.HashMap<java.lang.String,java.lang.Double>gaussMethod(Matrix A, Vector b, java.util.ArrayList<java.lang.String> variables)computes the solutions of the matrix equation Ax=b using the guassian methodstatic java.util.HashMap<java.lang.String,java.lang.Double>inverseA(Matrix A, Vector b, java.util.ArrayList<java.lang.String> variables)computes the solutions of the matrix equation Ax=b using the inverse of Astatic java.util.HashMap<java.lang.String,java.lang.Double>solve(int method, LinearEquation... equations)Takes in LinearEquation objects and then returns the solutionstatic java.util.HashMap<java.lang.String,java.lang.Double>solve(LinearEquation... equations)Takes in LinearEquation objects and then returns the solutionstatic java.util.HashMap<java.lang.String,java.lang.Double>solve(java.lang.String[] equations, java.lang.String[] variables)Takes in string equations and then solves themstatic java.util.HashMap<java.lang.String,java.lang.Double>solve(java.lang.String[] equations, java.lang.String[] variables, int method)Takes in string equations and then solves themstatic java.util.HashMap<java.lang.String,java.lang.Double>solve(java.util.ArrayList<LinearEquation> equations)Takes in LinearEquation objects and then returns the solutionstatic java.util.HashMap<java.lang.String,java.lang.Double>solve(java.util.ArrayList<LinearEquation> equations, int method)Takes in LinearEquation objects and then returns the solution
-
-
-
Field Detail
-
CRAMARS_RULE
public static final int CRAMARS_RULE
constant for Cramar's Rule- See Also:
- Constant Field Values
-
GAUSS_METHOD
public static final int GAUSS_METHOD
constant for Gauss Method- See Also:
- Constant Field Values
-
INVERSE_METHOD
public static final int INVERSE_METHOD
constant for Inverse Method- See Also:
- Constant Field Values
-
-
Method Detail
-
solve
public static java.util.HashMap<java.lang.String,java.lang.Double> solve(java.util.ArrayList<LinearEquation> equations)
Takes in LinearEquation objects and then returns the solution- Parameters:
equations- an ArrayList of the LinearEquations- Returns:
- the solutions of the equations
-
solve
public static java.util.HashMap<java.lang.String,java.lang.Double> solve(java.util.ArrayList<LinearEquation> equations, int method)
Takes in LinearEquation objects and then returns the solution- Parameters:
equations- an ArrayList of the LinearEquationsmethod- int defining the method to use to solve this- Returns:
- the solutions of the equations
-
cramarsRule
public static java.util.HashMap<java.lang.String,java.lang.Double> cramarsRule(Matrix A, Vector b, java.util.ArrayList<java.lang.String> variables)
computes the solutions of the matrix equation Ax=b using cramar's rule- Parameters:
A- a matrix for the equationb- a vector for the equationvariables- the variable names- Returns:
- the solutions to the matrix equation
-
gaussMethod
public static java.util.HashMap<java.lang.String,java.lang.Double> gaussMethod(Matrix A, Vector b, java.util.ArrayList<java.lang.String> variables)
computes the solutions of the matrix equation Ax=b using the guassian method- Parameters:
A- a matrix for the equationb- a vector for the equationvariables- the variable names- Returns:
- the solutions to the matrix equation
-
inverseA
public static java.util.HashMap<java.lang.String,java.lang.Double> inverseA(Matrix A, Vector b, java.util.ArrayList<java.lang.String> variables)
computes the solutions of the matrix equation Ax=b using the inverse of A- Parameters:
A- a matrix for the equationb- a vector for the equationvariables- the variable names- Returns:
- the solutions to the matrix equation
-
solve
public static java.util.HashMap<java.lang.String,java.lang.Double> solve(LinearEquation... equations)
Takes in LinearEquation objects and then returns the solution- Parameters:
equations- an ArrayList of the LinearEquations- Returns:
- the solutions of the equations
-
solve
public static java.util.HashMap<java.lang.String,java.lang.Double> solve(int method, LinearEquation... equations)Takes in LinearEquation objects and then returns the solution- Parameters:
equations- an ArrayList of the LinearEquationsmethod- int defining the method to use to solve this- Returns:
- the solutions of the equations
-
solve
public static java.util.HashMap<java.lang.String,java.lang.Double> solve(java.lang.String[] equations, java.lang.String[] variables, int method)Takes in string equations and then solves them- Parameters:
equations- the string equationsvariables- the variables to solve formethod- int defining the method to use to solve this- Returns:
- the solutions of the equations
-
solve
public static java.util.HashMap<java.lang.String,java.lang.Double> solve(java.lang.String[] equations, java.lang.String[] variables)Takes in string equations and then solves them- Parameters:
equations- the string equationsvariables- the variables to solve for- Returns:
- the solutions of the equations
-
-