Package pal.math

Class Matrix

java.lang.Object
pal.math.Matrix

public final class Matrix extends Object

Title: Matrix

Description: A very simple implementation of a general matrix. Not really that useful. Will probably become an interface at some point, with this class as a default implementation (so that users may switch to alternative libraries such as Jama)

Version:
1.0
Author:
Matthew Goode
  • Constructor Details

    • Matrix

      public Matrix(int size, boolean identity)
    • Matrix

      public Matrix(int width, int height)
    • Matrix

      public Matrix(double[][] data)
  • Method Details

    • toArray

      public double[] toArray()
    • setValue

      public final void setValue(int row, int col, double value)
    • getValue

      public final double getValue(int row, int col)
    • isSquare

      public final boolean isSquare()
    • getWidth

      public final int getWidth()
    • getHeight

      public final int getHeight()
    • getAppendedHorizontally

      public Matrix getAppendedHorizontally(Matrix other)
      Returns:
      a new Matrix that is this matrix with other appended on the end (eg [this | other ])
    • getAppendedVertically

      public Matrix getAppendedVertically(Matrix other)
      Returns:
      a new Matrix that is this matrix with other appended on the bottom (eg [this / other ]
    • getSubsetColumns

      public Matrix getSubsetColumns(int startColumn, int numberToKeep)
      Returns a new Matrix that is formed from a subset of the colums of this matrix
      Parameters:
      startColumn - the first column to include in new Matrix
      numberToKeep - the number of columns to keep
    • transpose

      public final void transpose()
    • getTranspose

      public final Matrix getTranspose()
    • multiply

      public final void multiply(double scale)
    • getMultiplied

      public final Matrix getMultiplied(Matrix other)
      Multiply as in [this][other]
    • getMultiplied

      public final Matrix getMultiplied(double scale)
    • getInverse

      public Matrix getInverse()
      Obtains the inverse of a matrix by appending identity and doing row reduction. May not be the most accurate way of doing things (errors tend to accumulate)
      Returns:
      The inverse of this matrix
    • rowReduce

      public void rowReduce()
    • getRowReduced

      public Matrix getRowReduced()
      Peforms a simple row reduction tramsformation
      Returns:
      A row reduced version of this matrix
    • getMatrixCopy

      public Matrix getMatrixCopy()
      Cloning
      Returns:
      an exact copy of this matrix
    • toString

      public String toString()
      Overrides:
      toString in class Object