Class LinearSolver

java.lang.Object
cc.redberry.rings.linear.LinearSolver

public final class LinearSolver
extends Object
Solver for quadratic linear system
Since:
1.0
  • Nested Class Summary

    Nested Classes
    Modifier and Type Class Description
    static class  LinearSolver.SystemInfo
    Info about linear system
  • Method Summary

    Modifier and Type Method Description
    static void reducedRowEchelonForm​(IntegersZp64 ring, long[][] lhs, long[] rhs)
    Gives the reduced row echelon form of the linear system lhs.x = rhs from a given row echelon form.
    static <E> void reducedRowEchelonForm​(Ring<E> ring, E[][] lhs, E[] rhs)
    Gives the reduced row echelon form of the linear system lhs.x = rhs from a given row echelon form.
    static int rowEchelonForm​(IntegersZp64 ring, long[][] matrix)
    Gives the row echelon form of the matrix
    static int rowEchelonForm​(IntegersZp64 ring, long[][] matrix, boolean reduce)
    Gives the row echelon form of the matrix
    static int rowEchelonForm​(IntegersZp64 ring, long[][] lhs, long[] rhs)
    Gives the row echelon form of the linear system lhs.x = rhs (rhs may be null).
    static int rowEchelonForm​(IntegersZp64 ring, long[][] lhs, long[] rhs, boolean reduce, boolean breakOnUnderDetermined)
    Gives the row echelon form of the linear system lhs.x = rhs (rhs may be null).
    static <E> int rowEchelonForm​(Ring<E> ring, E[][] matrix)
    Gives the row echelon form of the matrix
    static <E> int rowEchelonForm​(Ring<E> ring, E[][] matrix, boolean reduce)
    Gives the row echelon form of the matrix
    static <E> int rowEchelonForm​(Ring<E> ring, E[][] lhs, E[] rhs)
    Gives the row echelon form of the linear system lhs.x = rhs.
    static <E> int rowEchelonForm​(Ring<E> ring, E[][] lhs, E[] rhs, boolean reduce, boolean breakOnUnderDetermined)
    Gives the row echelon form of the linear system lhs.x = rhs.
    static long[] solve​(IntegersZp64 ring, long[][] lhs, long[] rhs)
    Solves linear system lhs.x = rhs and reduces the lhs to row echelon form.
    static LinearSolver.SystemInfo solve​(IntegersZp64 ring, long[][] lhs, long[] rhs, long[] result)
    Solves linear system lhs.x = rhs and reduces the lhs to row echelon form.
    static LinearSolver.SystemInfo solve​(IntegersZp64 ring, long[][] lhs, long[] rhs, long[] result, boolean solveIfUnderDetermined)
    Solves linear system lhs.x = rhs and reduces the lhs to row echelon form.
    static LinearSolver.SystemInfo solve​(IntegersZp64 ring, ArrayList<long[]> lhs, gnu.trove.list.array.TLongArrayList rhs, long[] result)
    Solves linear system lhs.x = rhs and stores the result in result (which should be of the enough length).
    static <E> E[] solve​(Ring<E> ring, E[][] lhs, E[] rhs)
    Solves linear system lhs.x = rhs and reduces lhs to row echelon form.
    static <E> LinearSolver.SystemInfo solve​(Ring<E> ring, E[][] lhs, E[] rhs, E[] result)
    Solves linear system lhs.x = rhs and reduces the lhs to row echelon form.
    static <E> LinearSolver.SystemInfo solve​(Ring<E> ring, E[][] lhs, E[] rhs, E[] result, boolean solveIfUnderDetermined)
    Solves linear system lhs.x = rhs and reduces the lhs to row echelon form.
    static <E> LinearSolver.SystemInfo solve​(Ring<E> ring, ArrayList<E[]> lhs, ArrayList<E> rhs, E[] result)
    Solves linear system lhs.x = rhs and stores the result in result (which should be of the enough length).
    static long[] solveVandermonde​(IntegersZp64 ring, long[] row, long[] rhs)
    Solves Vandermonde linear system (that is with i-th equation of the form row[i]^0 * x0 + row[i]^1 * x1 + ... row[i]^N * xN = rhs[i] ).
    static LinearSolver.SystemInfo solveVandermonde​(IntegersZp64 ring, long[] row, long[] rhs, long[] result)
    Solves Vandermonde linear system (that is with i-th equation of the form row[i]^0 * x0 + row[i]^1 * x1 + ... row[i]^N * xN = rhs[i] ) and stores the result in result (which should be of the enough length).
    static <E> E[] solveVandermonde​(Ring<E> ring, E[] row, E[] rhs)
    Solves Vandermonde linear system (that is with i-th equation of the form row[i]^0 * x0 + row[i]^1 * x1 + ... row[i]^N * xN = rhs[i] ).
    static <E> LinearSolver.SystemInfo solveVandermonde​(Ring<E> ring, E[] row, E[] rhs, E[] result)
    Solves Vandermonde linear system (that is with i-th equation of the form row[i]^0 * x0 + row[i]^1 * x1 + ... row[i]^N * xN = rhs[i] ) and stores the result in result (which should be of the enough length).
    static long[] solveVandermondeT​(IntegersZp64 ring, long[] row, long[] rhs)
    Solves transposed Vandermonde linear system (that is with i-th equation of the form row[0]^i * x0 + row[1]^i * x1 + ... row[N]^i * xN = rhs[i] ).
    static LinearSolver.SystemInfo solveVandermondeT​(IntegersZp64 ring, long[] row, long[] rhs, long[] result)
    Solves transposed Vandermonde linear system (that is with i-th equation of the form row[0]^i * x0 + row[1]^i * x1 + ... row[N]^i * xN = rhs[i] ) and stores the result in result (which should be of the enough length).
    static <E> E[] solveVandermondeT​(Ring<E> ring, E[] row, E[] rhs)
    Solves transposed Vandermonde linear system (that is with i-th equation of the form row[0]^i * x0 + row[1]^i * x1 + ... row[N]^i * xN = rhs[i] ).
    static <E> LinearSolver.SystemInfo solveVandermondeT​(Ring<E> ring, E[] row, E[] rhs, E[] result)
    Solves transposed Vandermonde linear system (that is with i-th equation of the form row[0]^i * x0 + row[1]^i * x1 + ... row[N]^i * xN = rhs[i] ) and stores the result in result (which should be of the enough length).
    static void transposeSquare​(long[][] matrix)
    Transpose square matrix
    static void transposeSquare​(Object[][] matrix)
    Transpose square matrix

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • transposeSquare

      public static void transposeSquare​(Object[][] matrix)
      Transpose square matrix
    • transposeSquare

      public static void transposeSquare​(long[][] matrix)
      Transpose square matrix
    • rowEchelonForm

      public static <E> int rowEchelonForm​(Ring<E> ring, E[][] matrix)
      Gives the row echelon form of the matrix
      Parameters:
      ring - the ring
      matrix - the matrix
      Returns:
      the number of free variables
    • rowEchelonForm

      public static <E> int rowEchelonForm​(Ring<E> ring, E[][] matrix, boolean reduce)
      Gives the row echelon form of the matrix
      Parameters:
      ring - the ring
      matrix - the matrix
      reduce - whether to calculate reduced row echelon form
      Returns:
      the number of free variables
    • rowEchelonForm

      public static <E> int rowEchelonForm​(Ring<E> ring, E[][] lhs, E[] rhs)
      Gives the row echelon form of the linear system lhs.x = rhs.
      Parameters:
      ring - the ring
      lhs - the lhs of the system
      rhs - the rhs of the system
      Returns:
      the number of free variables
    • rowEchelonForm

      public static <E> int rowEchelonForm​(Ring<E> ring, E[][] lhs, E[] rhs, boolean reduce, boolean breakOnUnderDetermined)
      Gives the row echelon form of the linear system lhs.x = rhs.
      Parameters:
      ring - the ring
      lhs - the lhs of the system
      rhs - the rhs of the system
      reduce - whether to calculate reduced row echelon form
      breakOnUnderDetermined - whether to return immediately if it was detected that system is under determined
      Returns:
      the number of free variables
    • reducedRowEchelonForm

      public static <E> void reducedRowEchelonForm​(Ring<E> ring, E[][] lhs, E[] rhs)
      Gives the reduced row echelon form of the linear system lhs.x = rhs from a given row echelon form.
      Parameters:
      ring - the ring
      lhs - the lhs of the system in the row echelon form
      rhs - the rhs of the system
    • solve

      public static <E> E[] solve​(Ring<E> ring, E[][] lhs, E[] rhs)
      Solves linear system lhs.x = rhs and reduces lhs to row echelon form.
      Parameters:
      ring - the ring
      lhs - the lhs of the system (will be reduced to row echelon form)
      rhs - the rhs of the system
      Returns:
      the solution
      Throws:
      ArithmeticException - if the system is inconsistent or under-determined
    • solve

      public static <E> LinearSolver.SystemInfo solve​(Ring<E> ring, E[][] lhs, E[] rhs, E[] result)
      Solves linear system lhs.x = rhs and reduces the lhs to row echelon form. The result is stored in result (which should be of the enough length).
      Parameters:
      ring - the ring
      lhs - the lhs of the system (will be reduced to row echelon form)
      rhs - the rhs of the system
      result - where to place the result
      Returns:
      system information (inconsistent, under-determined or consistent)
    • solve

      public static <E> LinearSolver.SystemInfo solve​(Ring<E> ring, E[][] lhs, E[] rhs, E[] result, boolean solveIfUnderDetermined)
      Solves linear system lhs.x = rhs and reduces the lhs to row echelon form. The result is stored in result (which should be of the enough length).
      Parameters:
      ring - the ring
      lhs - the lhs of the system (will be reduced to row echelon form)
      rhs - the rhs of the system
      result - where to place the result
      solveIfUnderDetermined - give some solution even if the system is under determined
      Returns:
      system information (inconsistent, under-determined or consistent)
    • solve

      public static <E> LinearSolver.SystemInfo solve​(Ring<E> ring, ArrayList<E[]> lhs, ArrayList<E> rhs, E[] result)
      Solves linear system lhs.x = rhs and stores the result in result (which should be of the enough length).
      Parameters:
      ring - the ring
      lhs - the lhs of the system
      rhs - the rhs of the system
      result - where to place the result
      Returns:
      system information (inconsistent, under-determined or consistent)
    • solveVandermonde

      public static <E> E[] solveVandermonde​(Ring<E> ring, E[] row, E[] rhs)
      Solves Vandermonde linear system (that is with i-th equation of the form row[i]^0 * x0 + row[i]^1 * x1 + ... row[i]^N * xN = rhs[i] ).
      Parameters:
      ring - the ring
      row - the Vandermonde coefficients
      rhs - the rhs of the system
      Returns:
      the solution
      Throws:
      ArithmeticException - if the system is inconsistent or under-determined
    • solveVandermondeT

      public static <E> E[] solveVandermondeT​(Ring<E> ring, E[] row, E[] rhs)
      Solves transposed Vandermonde linear system (that is with i-th equation of the form row[0]^i * x0 + row[1]^i * x1 + ... row[N]^i * xN = rhs[i] ).
      Parameters:
      ring - the ring
      row - the Vandermonde coefficients
      rhs - the rhs of the system
      Returns:
      the solution
      Throws:
      ArithmeticException - if the system is inconsistent or under-determined
    • solveVandermonde

      public static <E> LinearSolver.SystemInfo solveVandermonde​(Ring<E> ring, E[] row, E[] rhs, E[] result)
      Solves Vandermonde linear system (that is with i-th equation of the form row[i]^0 * x0 + row[i]^1 * x1 + ... row[i]^N * xN = rhs[i] ) and stores the result in result (which should be of the enough length).
      Parameters:
      ring - the ring
      row - the Vandermonde coefficients
      rhs - the rhs of the system
      result - where to place the result
      Returns:
      system information (inconsistent, under-determined or consistent)
    • solveVandermondeT

      public static <E> LinearSolver.SystemInfo solveVandermondeT​(Ring<E> ring, E[] row, E[] rhs, E[] result)
      Solves transposed Vandermonde linear system (that is with i-th equation of the form row[0]^i * x0 + row[1]^i * x1 + ... row[N]^i * xN = rhs[i] ) and stores the result in result (which should be of the enough length).
      Parameters:
      ring - the ring
      row - the Vandermonde coefficients
      rhs - the rhs of the system
      result - where to place the result
      Returns:
      system information (inconsistent, under-determined or consistent)
    • rowEchelonForm

      public static int rowEchelonForm​(IntegersZp64 ring, long[][] matrix)
      Gives the row echelon form of the matrix
      Parameters:
      ring - the ring
      matrix - the matrix
      Returns:
      the number of free variables
    • rowEchelonForm

      public static int rowEchelonForm​(IntegersZp64 ring, long[][] matrix, boolean reduce)
      Gives the row echelon form of the matrix
      Parameters:
      ring - the ring
      matrix - the matrix
      reduce - whether to calculate reduced row echelon form
      Returns:
      the number of free variables
    • rowEchelonForm

      public static int rowEchelonForm​(IntegersZp64 ring, long[][] lhs, long[] rhs)
      Gives the row echelon form of the linear system lhs.x = rhs (rhs may be null).
      Parameters:
      ring - the ring
      lhs - the lhs of the system
      rhs - the rhs of the system (may be null)
      Returns:
      the number of free variables
    • rowEchelonForm

      public static int rowEchelonForm​(IntegersZp64 ring, long[][] lhs, long[] rhs, boolean reduce, boolean breakOnUnderDetermined)
      Gives the row echelon form of the linear system lhs.x = rhs (rhs may be null).
      Parameters:
      ring - the ring
      lhs - the lhs of the system
      rhs - the rhs of the system (may be null)
      reduce - whether to calculate reduced row echelon form
      breakOnUnderDetermined - whether to return immediately if it was detected that system is under determined
      Returns:
      the number of free variables
    • reducedRowEchelonForm

      public static void reducedRowEchelonForm​(IntegersZp64 ring, long[][] lhs, long[] rhs)
      Gives the reduced row echelon form of the linear system lhs.x = rhs from a given row echelon form.
      Parameters:
      ring - the ring
      lhs - the lhs of the system in the row echelon form
      rhs - the rhs of the system
    • solve

      public static long[] solve​(IntegersZp64 ring, long[][] lhs, long[] rhs)
      Solves linear system lhs.x = rhs and reduces the lhs to row echelon form.
      Parameters:
      ring - the ring
      lhs - the lhs of the system (will be reduced to row echelon form)
      rhs - the rhs of the system
      Returns:
      the solution
      Throws:
      ArithmeticException - if the system is inconsistent or under-determined
    • solve

      public static LinearSolver.SystemInfo solve​(IntegersZp64 ring, long[][] lhs, long[] rhs, long[] result)
      Solves linear system lhs.x = rhs and reduces the lhs to row echelon form. The result is stored in result (which should be of the enough length).
      Parameters:
      ring - the ring
      lhs - the lhs of the system (will be reduced to row echelon form)
      rhs - the rhs of the system
      result - where to place the result
      Returns:
      system information (inconsistent, under-determined or consistent)
    • solve

      public static LinearSolver.SystemInfo solve​(IntegersZp64 ring, long[][] lhs, long[] rhs, long[] result, boolean solveIfUnderDetermined)
      Solves linear system lhs.x = rhs and reduces the lhs to row echelon form. The result is stored in result (which should be of the enough length and filled with zeros).
      Parameters:
      ring - the ring
      lhs - the lhs of the system (will be reduced to row echelon form)
      rhs - the rhs of the system
      result - where to place the result
      solveIfUnderDetermined - give some solution even if the system is under determined
      Returns:
      system information (inconsistent, under-determined or consistent)
    • solve

      public static LinearSolver.SystemInfo solve​(IntegersZp64 ring, ArrayList<long[]> lhs, gnu.trove.list.array.TLongArrayList rhs, long[] result)
      Solves linear system lhs.x = rhs and stores the result in result (which should be of the enough length).
      Parameters:
      ring - the ring
      lhs - the lhs of the system
      rhs - the rhs of the system
      result - where to place the result
      Returns:
      system information (inconsistent, under-determined or consistent)
    • solveVandermonde

      public static long[] solveVandermonde​(IntegersZp64 ring, long[] row, long[] rhs)
      Solves Vandermonde linear system (that is with i-th equation of the form row[i]^0 * x0 + row[i]^1 * x1 + ... row[i]^N * xN = rhs[i] ).
      Parameters:
      ring - the ring
      row - the Vandermonde coefficients
      rhs - the rhs of the system
      Returns:
      the solution
      Throws:
      ArithmeticException - if the system is inconsistent or under-determined
    • solveVandermondeT

      public static long[] solveVandermondeT​(IntegersZp64 ring, long[] row, long[] rhs)
      Solves transposed Vandermonde linear system (that is with i-th equation of the form row[0]^i * x0 + row[1]^i * x1 + ... row[N]^i * xN = rhs[i] ).
      Parameters:
      ring - the ring
      row - the Vandermonde coefficients
      rhs - the rhs of the system
      Returns:
      the solution
      Throws:
      ArithmeticException - if the system is inconsistent or under-determined
    • solveVandermonde

      public static LinearSolver.SystemInfo solveVandermonde​(IntegersZp64 ring, long[] row, long[] rhs, long[] result)
      Solves Vandermonde linear system (that is with i-th equation of the form row[i]^0 * x0 + row[i]^1 * x1 + ... row[i]^N * xN = rhs[i] ) and stores the result in result (which should be of the enough length).
      Parameters:
      ring - the ring
      row - the Vandermonde coefficients
      rhs - the rhs of the system
      result - where to place the result
      Returns:
      system information (inconsistent, under-determined or consistent)
    • solveVandermondeT

      public static LinearSolver.SystemInfo solveVandermondeT​(IntegersZp64 ring, long[] row, long[] rhs, long[] result)
      Solves transposed Vandermonde linear system (that is with i-th equation of the form row[0]^i * x0 + row[1]^i * x1 + ... row[N]^i * xN = rhs[i] ) and stores the result in result (which should be of the enough length).
      Parameters:
      ring - the ring
      row - the Vandermonde coefficients
      rhs - the rhs of the system
      result - where to place the result
      Returns:
      system information (inconsistent, under-determined or consistent)