Class Matrix

java.lang.Object
org.tweetyproject.math.matrix.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.
  • Method Summary

    Modifier and Type
    Method
    Description
    add(Matrix other)
    Adds the given matrix to this one and returns the result.
    double
    Returns the distance of this matrix to the zero matrix.
    getEntry(int x, int y)
    Returns the entry with the given coordinates.
    static Matrix
    Returns the identity matrix of the given dimension.
    Jama.Matrix
    Creates the Jama matrix representation of this matrix.
    int
    Returns the x dimension of this matrix.
    int
    Returns the y dimension of this matrix.
    boolean
    Checks whether each entry in this matrix describes a finite number.
    minus(Matrix other)
    Makes a subtraction of the given matrix from this one and returns the result.
    mult(double scalar)
    Multiply this matrix with the given scalar (every entry is multiplied)
    mult(Matrix other)
    Multiply this matrix with the given one.
    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.
    Simplifies every entry.
     
    Transposes this matrix, i.e.

    Methods inherited from class java.lang.Object

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

    • 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 Details

    • 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.
    • add

      public Matrix add(Matrix other) throws IllegalArgumentException
      Adds the given matrix to this one and returns the result.
      Parameters:
      other - a matrix
      Returns:
      the sum of the two matrices.
      Throws:
      IllegalArgumentException - if the dimensions of the matrices do not correspond.
    • 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.
    • toString

      public String toString()
      Overrides:
      toString in class Object