Documentation of 'edu.rit.numeric.LinearSolve' Java class
LinearSolve
edu.rit.numeric

Class LinearSolve



  • public class LinearSolve
    extends java.lang.Object
    Class LinearSolve provides an object for solving a system of linear equations using LU decomposition. The solve() method finds a solution to the system of linear equations Ax = b, where A is a square matrix supplied to the constructor and b is a vector supplied to the solve() method. Thus, an instance of class LinearSolve can be used to solve many linear systems with the same left-hand-side matrix and different right-hand-side vectors.

    The Java code for LU decomposition was translated from routine gsl_linalg_LU_decomp() in the GNU Scientific Library.

    • Constructor Summary

      Constructors 
      Constructor and Description
      LinearSolve(double[][] A)
      Construct a new LinearSolve object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      double determinant()
      Compute det A, the determinant of A.
      void invert(double[][] Ainv)
      Compute A-1, the inverse of A.
      void invertMultiply(double[][] AinvB, double[][] B)
      Compute A-1B.
      void solve(double[] x, double[] b)
      Solve the linear system Ax = b.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LinearSolve

        public LinearSolve(double[][] A)
        Construct a new LinearSolve object. A must be an N-by-N matrix with N > 0. This constructor calculates the LU decomposition of A and stores the result internally; A is unchanged.
        Parameters:
        A - Left-hand-side matrix.
        Throws:
        java.lang.NullPointerException - (unchecked exception) Thrown if A or any row thereof is null.
        java.lang.IllegalArgumentException - (unchecked exception) Thrown if A is zero length or is not a square matrix.
        DomainException - (unchecked exception) Thrown if a zero pivot was encountered during the LU decomposition.
    • Method Detail

      • solve

        public void solve(double[] x,
                          double[] b)
        Solve the linear system Ax = b. A is the N-by-N matrix supplied to the constructor. b must be an N-element array initialized to the right-hand-side vector. The solution vector is stored in the N-element array x. b and x must be different arrays.
        Parameters:
        x - Solution vector (output).
        b - Right-hand-side vector (input).
        Throws:
        java.lang.NullPointerException - (unchecked exception) Thrown if x or b is null.
        java.lang.IllegalArgumentException - (unchecked exception) Thrown if x's length or b's length is not N.
      • invert

        public void invert(double[][] Ainv)
        Compute A-1, the inverse of A. A is the N-by-N matrix supplied to the constructor. The inverse of A is stored in the N-by-N matrix Ainv.
        Parameters:
        Ainv - Inverse matrix (output).
        Throws:
        java.lang.NullPointerException - (unchecked exception) Thrown if Ainv or any row thereof is null.
        java.lang.IllegalArgumentException - (unchecked exception) Thrown if Ainv is not an N-by-N matrix.
      • invertMultiply

        public void invertMultiply(double[][] AinvB,
                                   double[][] B)
        Compute A-1B. A is the N-by-N matrix supplied to the constructor. B must be an N-by-N matrix. The matrix product of A-1 and B is stored in the N-by-N matrix AinvB.
        Parameters:
        AinvB - Product matrix (output).
        B - Matrix (input).
        Throws:
        java.lang.NullPointerException - (unchecked exception) Thrown if AinvB, B, or any row thereof is null.
        java.lang.IllegalArgumentException - (unchecked exception) Thrown if AinvB or B is not an N-by-N matrix.
      • determinant

        public double determinant()
        Compute det A, the determinant of A. A is the N-by-N matrix supplied to the constructor. Note that for larger matrices, det A may overflow or underflow the dynamic range of type double.
        Returns:
        The determinant of A.

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.