Class Matrix


  • public class Matrix
    extends java.lang.Object
    This class models a matrix of terms.
    Author:
    Matthias Thimm
    • Constructor Summary

      Constructors 
      Constructor Description
      Matrix​(int n, int m)
      Creates a new matrix of the given dimension.
    • Method Summary

      Modifier and Type Method Description
      Matrix add​(Matrix other)
      Adds the given matrix to this one and returns the result.
      double distanceToZero()
      Returns the distance of this matrix to the zero matrix.
      Term getEntry​(int x, int y)
      Returns the entry with the given coordinates.
      static Matrix getIdentityMatrix​(int dim)
      Returns the identity matrix of the given dimension.
      Jama.Matrix getJamaMatrix()
      Creates the Jama matrix representation of this matrix.
      int getXDimension()
      Returns the x dimension of this matrix.
      int getYDimension()
      Returns the y dimension of this matrix.
      boolean isFinite()
      Checks whether each entry in this matrix describes a finite number.
      Matrix minus​(Matrix other)
      Makes a subtraction of the given matrix from this one and returns the result.
      Matrix mult​(double scalar)
      Multiply this matrix with the given scalar (every entry is multiplied)
      Matrix mult​(Matrix other)
      Multiply this matrix with the given one.
      Matrix mult​(Term scalar)
      Multiply this matrix with the given scalar (every entry is multiplied)
      void setEntry​(int x, int y, Term entry)
      Sets the entry at the given coordinates.
      Matrix simplify()
      Simplifies every entry.
      java.lang.String toString()  
      Matrix transpose()
      Transposes this matrix, i.e.
      • Methods inherited from class java.lang.Object

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

      • Matrix

        public Matrix​(int n,
                      int m)
        Creates a new matrix of the given dimension.
        Parameters:
        n - the x dimension of the matrix.
        m - the y dimension of the matrix.
    • Method Detail

      • getEntry

        public Term getEntry​(int x,
                             int y)
        Returns the entry with the given coordinates.
        Parameters:
        x - the x coordinate of the entry.
        y - the y coordinate of the entry.
        Returns:
        the entry at the given coordinates.
      • setEntry

        public void setEntry​(int x,
                             int y,
                             Term entry)
        Sets the entry at the given coordinates.
        Parameters:
        x - the x coordinate of the entry.
        y - the y coordinate of the entry.
        entry - the entry to be set.
      • getXDimension

        public int getXDimension()
        Returns the x dimension of this matrix.
        Returns:
        the x dimension of this matrix.
      • getYDimension

        public int getYDimension()
        Returns the y dimension of this matrix.
        Returns:
        the y dimension of this matrix.
      • mult

        public Matrix mult​(Matrix other)
                    throws java.lang.IllegalArgumentException
        Multiply this matrix with the given one.
        Parameters:
        other - a matrix
        Returns:
        the product of the two matrices.
        Throws:
        java.lang.IllegalArgumentException - if the x dimension of this matrix does not equal the y dimension of the other matrix
      • mult

        public Matrix mult​(Term scalar)
        Multiply this matrix with the given scalar (every entry is multiplied)
        Parameters:
        scalar - a term
        Returns:
        a new matrix.
      • mult

        public Matrix mult​(double scalar)
        Multiply this matrix with the given scalar (every entry is multiplied)
        Parameters:
        scalar - a double
        Returns:
        a new matrix.
      • transpose

        public Matrix transpose()
        Transposes this matrix, i.e. switches x and y dimension.
        Returns:
        the transposed matrix.
      • add

        public Matrix add​(Matrix other)
                   throws java.lang.IllegalArgumentException
        Adds the given matrix to this one and returns the result.
        Parameters:
        other - a matrix
        Returns:
        the sum of the two matrices.
        Throws:
        java.lang.IllegalArgumentException - if the dimensions of the matrices do not correspond.
      • minus

        public Matrix minus​(Matrix other)
                     throws java.lang.IllegalArgumentException
        Makes a subtraction of the given matrix from this one and returns the result.
        Parameters:
        other - a matrix
        Returns:
        the subtraction of the two matrices.
        Throws:
        java.lang.IllegalArgumentException - if the dimensions of the matrices do not correspond.
      • simplify

        public Matrix simplify()
        Simplifies every entry.
        Returns:
        the simplified matrix.
      • getJamaMatrix

        public Jama.Matrix getJamaMatrix()
        Creates the Jama matrix representation of this matrix.
        Returns:
        the Jama matrix representation of this matrix.
      • distanceToZero

        public double distanceToZero()
        Returns the distance of this matrix to the zero matrix.
        Returns:
        the distance of this matrix to the zero matrix.
      • getIdentityMatrix

        public static Matrix getIdentityMatrix​(int dim)
        Returns the identity matrix of the given dimension.
        Parameters:
        dim - the dimension.
        Returns:
        the identity matrix of the given dimension.
      • isFinite

        public boolean isFinite()
        Checks whether each entry in this matrix describes a finite number.
        Returns:
        "true" iff this matrix is finite.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object