Class LinAlg<C extends RingElem<C>>

  • Type Parameters:
    C - coefficient type
    All Implemented Interfaces:
    java.io.Serializable

    public class LinAlg<C extends RingElem<C>>
    extends java.lang.Object
    implements java.io.Serializable
    Linear algebra methods. Implements linear algebra computations and tests, mainly based on Gauss elimination. Partly based on LU_decomposition. Computation of Null space basis, row echelon form, inverses and ranks.
    Author:
    Heinz Kredel
    See Also:
    Serialized Form
    • Constructor Detail

      • LinAlg

        public LinAlg()
        Constructor.
    • Method Detail

      • decompositionLU

        public java.util.List<java.lang.Integer> decompositionLU​(GenMatrix<C> A)
        Matrix LU decomposition. Matrix A is replaced by its LU decomposition. A contains a copy of both matrices L-E and U as A=(L-E)+U such that P*A=L*U. The permutation matrix is not stored as a matrix, but in an integer vector P of size N+1 containing column indexes where the permutation matrix has "1". The last element P[N]=S+N, where S is the number of row exchanges needed for determinant computation, det(P)=(-1)^S
        Parameters:
        A - a n×n matrix.
        Returns:
        permutation vector P and modified matrix A.
      • solveLU

        public GenVector<CsolveLU​(GenMatrix<C> A,
                                    java.util.List<java.lang.Integer> P,
                                    GenVector<C> b)
        Solve with LU decomposition.
        Parameters:
        A - a n×n matrix in LU decomposition.
        P - permutation vector.
        b - right hand side vector.
        Returns:
        x solution vector of A*x = b.
      • solve

        public GenVector<Csolve​(GenMatrix<C> A,
                                  GenVector<C> b)
        Solve linear system of equations.
        Parameters:
        A - a n×n matrix.
        b - right hand side vector.
        Returns:
        x solution vector of A*x = b.
      • determinantLU

        public C determinantLU​(GenMatrix<C> A,
                               java.util.List<java.lang.Integer> P)
        Determinant with LU decomposition.
        Parameters:
        A - a n×n matrix in LU decomposition.
        P - permutation vector.
        Returns:
        d determinant of A.
      • inverseLU

        public GenMatrix<CinverseLU​(GenMatrix<C> A,
                                      java.util.List<java.lang.Integer> P)
        Inverse with LU decomposition.
        Parameters:
        A - a n×n matrix in LU decomposition.
        P - permutation vector.
        Returns:
        inv(A) with A * inv(A) == 1.
      • nullSpaceBasis

        public java.util.List<GenVector<C>> nullSpaceBasis​(GenMatrix<C> A)
        Matrix Null Space basis, cokernel. From the transpose matrix At it computes the kernel with At*v_i = 0.
        Parameters:
        A - a n×n matrix.
        Returns:
        V a list of basis vectors (v_1, ..., v_k) with v_i*A == 0.
      • rankNS

        public long rankNS​(GenMatrix<C> A)
        Rank via null space.
        Parameters:
        A - a n×n matrix.
        Returns:
        r rank of A.
      • rowEchelonForm

        public GenMatrix<CrowEchelonForm​(GenMatrix<C> A)
        Matrix row echelon form construction. Matrix A is replaced by its row echelon form, an upper triangle matrix.
        Parameters:
        A - a n×m matrix.
        Returns:
        A row echelon form of A, matrix A is modified.
      • rankRE

        public long rankRE​(GenMatrix<C> A)
        Rank via row echelon form.
        Parameters:
        A - a n×n matrix.
        Returns:
        r rank of A.
      • rowEchelonFormSparse

        public GenMatrix<CrowEchelonFormSparse​(GenMatrix<C> A)
        Matrix row echelon form construction. Matrix A is replaced by its row echelon form, an upper triangle matrix with less non-zero entries. No column swaps and transforms are performed as with the Gauss-Jordan algorithm.
        Parameters:
        A - a n×m matrix.
        Returns:
        A sparse row echelon form of A, matrix A is modified.
      • fractionfreeGaussElimination

        public java.util.List<java.lang.Integer> fractionfreeGaussElimination​(GenMatrix<C> A)
        Matrix fraction free Gauss elimination. Matrix A is replaced by its fraction free LU decomposition. A contains a copy of both matrices L-E and U as A=(L-E)+U such that P*A=L*U. TODO: L is not computed but 0. The permutation matrix is not stored as a matrix, but in an integer vector P of size N+1 containing column indexes where the permutation matrix has "1". The last element P[N]=S+N, where S is the number of row exchanges needed for determinant computation, det(P)=(-1)^S
        Parameters:
        A - a n×n matrix.
        Returns:
        permutation vector P and modified matrix A.