Class LinEqSysSolver


  • public class LinEqSysSolver
    extends Object
    A gauss-based solver for linear equation systems.
    • Constructor Summary

      Constructors 
      Constructor Description
      LinEqSysSolver()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean gauss​(double[][] a, double[] c, double[] x, int n, double eps)
      Solves a linear equation system using the gaussian algorithm.
      static boolean gauss_debug​(double[][] a, double[] c, double[] x, int n, double eps)
      Same as the gausss method, but prints extra debug information.
      static boolean pivotize​(double[][] a, double[] c, int k, int n, double eps)
      Rearranges the matrix a by swapping line k with a suitable pivot line k'.
    • Constructor Detail

      • LinEqSysSolver

        public LinEqSysSolver()
    • Method Detail

      • gauss

        public static boolean gauss​(double[][] a,
                                    double[] c,
                                    double[] x,
                                    int n,
                                    double eps)
                             throws SingularMatrixException
        Solves a linear equation system using the gaussian algorithm.
        Parameters:
        a - coefficient matrix [0..n-1][0..n-1] (left side of equation)
        c - the constant vector [0..n-1] (right side of equation)
        x - the result vector [0..n-1] (right side of equation)
        n - number of coefficients
        eps - the epsilon value, e.g. 1.0e-09
        Throws:
        SingularMatrixException - if the matrix a is singular
      • gauss_debug

        public static boolean gauss_debug​(double[][] a,
                                          double[] c,
                                          double[] x,
                                          int n,
                                          double eps)
        Same as the gausss method, but prints extra debug information.
        Parameters:
        a - coefficient matrix [0..n-1][0..n-1] (left side of equation)
        c - the constant vector [0..n-1] (right side of equation)
        x - the result vector [0..n-1] (right side of equation)
        n - number of coefficients
        eps - the epsilon value, e.g. 1.0e-09
        Throws:
        SingularMatrixException - if the matrix a is singular
        See Also:
        gauss(double[][], double[], double[], int, double)
      • pivotize

        public static boolean pivotize​(double[][] a,
                                       double[] c,
                                       int k,
                                       int n,
                                       double eps)
        Rearranges the matrix a by swapping line k with a suitable pivot line k'.
        Parameters:
        a - coefficient matrix [0..n-1][0..n-1] (left side of equation)
        c - the constant vector [0..n-1] (right side of equation)
        k - the current index of a diagonal element = current line and column
        n - matrix size
        eps - the epsilon value, e.g. 1.0e-09
        Throws:
        SingularMatrixException - if the matrix a is singular