Package net.sf.tweety.math.matrix
Class Matrix
- java.lang.Object
-
- net.sf.tweety.math.matrix.Matrix
-
public class Matrix extends java.lang.ObjectThis 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 Matrixadd(Matrix other)Adds the given matrix to this one and returns the result.doubledistanceToZero()Returns the distance of this matrix to the zero matrix.TermgetEntry(int x, int y)Returns the entry with the given coordinates.static MatrixgetIdentityMatrix(int dim)Returns the identity matrix of the given dimension.Jama.MatrixgetJamaMatrix()Creates the Jama matrix representation of this matrix.intgetXDimension()Returns the x dimension of this matrix.intgetYDimension()Returns the y dimension of this matrix.booleanisFinite()Checks whether each entry in this matrix describes a finite number.Matrixminus(Matrix other)Makes a subtraction of the given matrix from this one and returns the result.Matrixmult(double scalar)Multiply this matrix with the given scalar (every entry is multiplied)Matrixmult(Matrix other)Multiply this matrix with the given one.Matrixmult(Term scalar)Multiply this matrix with the given scalar (every entry is multiplied)voidsetEntry(int x, int y, Term entry)Sets the entry at the given coordinates.Matrixsimplify()Simplifies every entry.java.lang.StringtoString()Matrixtranspose()Transposes this matrix, i.e.
-
-
-
Field Detail
-
entries
private Term[][] entries
The entries 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:
toStringin classjava.lang.Object
-
-