pal.math
Class Matrix

java.lang.Object
  extended by pal.math.Matrix

public final class Matrix
extends java.lang.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 Summary
Matrix(double[][] data)
           
Matrix(int size, boolean identity)
           
Matrix(int width, int height)
           
 
Method Summary
 Matrix getAppendedHorizontally(Matrix other)
           
 Matrix getAppendedVertically(Matrix other)
           
 int getHeight()
           
 Matrix getInverse()
          Obtains the inverse of a matrix by appending identity and doing row reduction.
 Matrix getMatrixCopy()
          Cloning
 Matrix getMultiplied(double scale)
           
 Matrix getMultiplied(Matrix other)
          Multiply as in [this][other]
 Matrix getRowReduced()
          Peforms a simple row reduction tramsformation
 Matrix getSubsetColumns(int startColumn, int numberToKeep)
          Returns a new Matrix that is formed from a subset of the colums of this matrix
 Matrix getTranspose()
           
 double getValue(int row, int col)
           
 int getWidth()
           
 boolean isSquare()
           
 void multiply(double scale)
           
 void rowReduce()
           
 void setValue(int row, int col, double value)
           
 double[] toArray()
           
 java.lang.String toString()
           
 void transpose()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Matrix

public Matrix(int size,
              boolean identity)

Matrix

public Matrix(int width,
              int height)

Matrix

public Matrix(double[][] data)
Method Detail

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 java.lang.String toString()
Overrides:
toString in class java.lang.Object