Class Matrix


  • public class Matrix
    extends 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.
    • 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 IllegalArgumentException
        Multiply this matrix with the given one.
        Parameters:
        other - a matrix
        Returns:
        the product of the two matrices.
        Throws:
        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.
      • minus

        public Matrix minus​(Matrix other)
                     throws 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:
        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.