Class GenMatrix<C extends RingElem<C>>

    • Field Detail

      • logger

        private static final org.apache.logging.log4j.Logger logger
      • matrix

        public final java.util.ArrayList<java.util.ArrayList<C extends RingElem<C>>> matrix
      • hashValue

        private int hashValue
    • Constructor Detail

      • GenMatrix

        public GenMatrix​(GenMatrixRing<C> r)
        Constructor for zero GenMatrix.
        Parameters:
        r - matrix ring
      • GenMatrix

        public GenMatrix​(GenMatrixRing<C> r,
                         java.util.List<java.util.List<C>> m)
        Constructor for GenMatrix.
        Parameters:
        r - matrix ring
        m - matrix
      • GenMatrix

        public GenMatrix​(GenMatrixRing<C> r,
                         java.util.ArrayList<java.util.ArrayList<C>> m)
        Constructor for GenMatrix.
        Parameters:
        r - matrix ring
        m - matrix
      • GenMatrix

        public GenMatrix​(GenMatrixRing<C> r,
                         C[][] m)
        Constructor for GenMatrix.
        Parameters:
        r - matrix ring
        m - matrix
    • Method Detail

      • get

        public C get​(int i,
                     int j)
        Get element at row i, column j.
        Parameters:
        i - row index.
        j - column index.
        Returns:
        this(i,j).
      • setMutate

        public void setMutate​(int i,
                              int j,
                              C el)
        Set element at row i, column j. Mutates this matrix.
        Parameters:
        i - row index.
        j - column index.
        el - element to set.
      • set

        public GenMatrix<C> set​(int i,
                                int j,
                                C el)
        Set element at row i, column j.
        Parameters:
        i - row index.
        j - column index.
        el - element to set.
        Returns:
        new matrix m, with m(i,j) == el.
      • getColumn

        public GenVector<C> getColumn​(int i)
        Get column i.
        Parameters:
        i - column index.
        Returns:
        this(*,i) as vector.
      • getRow

        public GenVector<C> getRow​(int i)
        Get row i.
        Parameters:
        i - row index.
        Returns:
        this(i,*) as vector.
      • getDiagonal

        public GenVector<C> getDiagonal()
        Get diagonal.
        Returns:
        diagonal(this) as vector.
      • trace

        public C trace()
        Trace.
        Returns:
        sum of diagonal elements.
      • getUpper

        public GenMatrix<C> getUpper()
        Get upper triangular U matrix.
        Returns:
        U as matrix with equal length rows.
      • getUpperScaled

        public GenMatrix<C> getUpperScaled()
        Get upper triangular U matrix with diagonal 1.
        Returns:
        U as matrix with equal length rows and diagonal 1.
      • getLower

        public GenMatrix<C> getLower()
        Get lower triangular L matrix.
        Returns:
        L as matrix with equal length rows.
      • toString

        public java.lang.String toString()
        Get the String representation as RingElem.
        Overrides:
        toString in class java.lang.Object
        See Also:
        Object.toString()
      • toScript

        public java.lang.String toScript()
        Get a scripting compatible string representation.
        Specified by:
        toScript in interface Element<C extends RingElem<C>>
        Returns:
        script compatible representation for this Element.
        See Also:
        Element.toScript()
      • toScriptFactory

        public java.lang.String toScriptFactory()
        Get a scripting compatible string representation of the factory.
        Specified by:
        toScriptFactory in interface Element<C extends RingElem<C>>
        Returns:
        script compatible representation for this ElemFactory.
        See Also:
        Element.toScriptFactory()
      • stack

        public GenMatrix<C> stack​(GenMatrixRing<C> st,
                                  GenMatrix<C> b)
        Stack method.
        Parameters:
        st - stacked matrix ring.
        b - other matrix.
        Returns:
        stacked matrix, this on top of other.
      • concat

        public GenMatrix<C> concat​(GenMatrixRing<C> cc,
                                   GenMatrix<C> b)
        Concat method.
        Parameters:
        cc - concated matrix ring.
        b - other matrix.
        Returns:
        concated matrix, this before of other.
      • isZERO

        public boolean isZERO()
        Test if this is equal to a zero matrix.
        Specified by:
        isZERO in interface AbelianGroupElem<C extends RingElem<C>>
        Returns:
        true if this is 0, else false.
      • isONE

        public boolean isONE()
        Test if this is one.
        Specified by:
        isONE in interface MonoidElem<C extends RingElem<C>>
        Returns:
        true if this is 1, else false.
      • isDiagonal

        public boolean isDiagonal()
        Test if this is a non-zero diagonal matrix.
        Returns:
        true if this is non-zero diagonal, else false.
      • equals

        public boolean equals​(java.lang.Object other)
        Comparison with any other object.
        Specified by:
        equals in interface Element<C extends RingElem<C>>
        Overrides:
        equals in class java.lang.Object
        Returns:
        true if this is equal to b, else false.
        See Also:
        Object.equals(java.lang.Object)
      • hashCode

        public int hashCode()
        Hash code for this GenMatrix.
        Specified by:
        hashCode in interface Element<C extends RingElem<C>>
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        the hashCode.
        See Also:
        Object.hashCode()
      • compareTo

        public int compareTo​(GenMatrix<C> b)
        compareTo, lexicogaphical comparison.
        Specified by:
        compareTo in interface java.lang.Comparable<C extends RingElem<C>>
        Specified by:
        compareTo in interface Element<C extends RingElem<C>>
        Parameters:
        b - other
        Returns:
        1 if (this < b), 0 if (this == b) or -1 if (this > b).
      • isUnit

        public boolean isUnit()
        Test if this is a unit. I.e. there exists x with this.multiply(x).isONE() == true. Tests if matrix is not singular. Was previously a test if all diagonal elements are units and all other elements are zero.
        Specified by:
        isUnit in interface MonoidElem<C extends RingElem<C>>
        Returns:
        true if this is a unit, else false.
      • signum

        public int signum()
        sign of matrix.
        Specified by:
        signum in interface AbelianGroupElem<C extends RingElem<C>>
        Returns:
        1 if (this < 0), 0 if (this == 0) or -1 if (this > 0).
      • multiply

        public GenMatrix<C> multiply​(C s)
        Product of this matrix with scalar.
        Parameters:
        s - scalar.
        Returns:
        this*s
      • leftScalarMultiply

        public GenMatrix<C> leftScalarMultiply​(C s)
        Left product of this matrix with scalar.
        Parameters:
        s - scalar
        Returns:
        s*this
      • linearCombination

        public GenMatrix<C> linearCombination​(C t,
                                              GenMatrix<C> b)
        Left linear combination of this matrix with scalar multiple of other matrix.
        Parameters:
        t - scalar
        b - other matrix.
        Returns:
        this+t*b
      • leftLinearCombination

        public GenMatrix<C> leftLinearCombination​(C s,
                                                  C t,
                                                  GenMatrix<C> b)
        left linear compination of this matrix with scalar multiple of other matrix.
        Parameters:
        s - scalar
        t - scalar
        b - other matrix.
        Returns:
        s*this+t*b
      • transpose

        public GenMatrix<C> transpose​(GenMatrixRing<C> tr)
        Transposed matrix.
        Parameters:
        tr - transposed matrix ring.
        Returns:
        transpose(this)
      • transpose

        public GenMatrix<C> transpose()
        Transposed matrix.
        Returns:
        transpose(this)
      • multiplySimple

        public GenMatrix<C> multiplySimple​(GenMatrix<C> S)
        Multiply this with S. Simple unblocked algorithm.
        Parameters:
        S - other matrix.
        Returns:
        this * S.
      • divideLeft

        public GenMatrix<C> divideLeft​(GenMatrix<C> S)
        Divide left this by S.
        Parameters:
        S - other matrix.
        Returns:
        S^{-1} * this.
      • egcd

        public GenMatrix<C>[] egcd​(GenMatrix<C> b)
        Extended greatest common divisor.
        Specified by:
        egcd in interface RingElem<C extends RingElem<C>>
        Parameters:
        b - other element.
        Returns:
        [ gcd(this,b), c1, c2 ] with c1*this + c2*b = gcd(this,b).