Package pal.math
Class Matrix
- java.lang.Object
-
- 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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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()
CloningMatrix
getMultiplied(double scale)
Matrix
getMultiplied(Matrix other)
Multiply as in [this][other]Matrix
getRowReduced()
Peforms a simple row reduction tramsformationMatrix
getSubsetColumns(int startColumn, int numberToKeep)
Returns a new Matrix that is formed from a subset of the colums of this matrixMatrix
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()
-
-
-
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 MatrixnumberToKeep
- 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(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 classjava.lang.Object
-
-