Class LinearEquationSolver


  • public class LinearEquationSolver
    extends java.lang.Object
    a class to solve linear equations
    Author:
    Bhagat
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int CRAMARS_RULE
      constant for Cramar's Rule
      static int GAUSS_METHOD
      constant for Gauss Method
      static int INVERSE_METHOD
      constant for Inverse Method
    • 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 rule
      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
      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
      static java.util.HashMap<java.lang.String,​java.lang.Double> solve​(int method, LinearEquation... equations)
      Takes in LinearEquation objects and then returns the solution
      static java.util.HashMap<java.lang.String,​java.lang.Double> solve​(LinearEquation... equations)
      Takes in LinearEquation objects and then returns the solution
      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
      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
      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
      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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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
    • Constructor Detail

      • LinearEquationSolver

        public LinearEquationSolver()
    • 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 LinearEquations
        method - 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 equation
        b - a vector for the equation
        variables - 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 equation
        b - a vector for the equation
        variables - 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 equation
        b - a vector for the equation
        variables - 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 LinearEquations
        method - 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 equations
        variables - the variables to solve for
        method - 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 equations
        variables - the variables to solve for
        Returns:
        the solutions of the equations