Package pal.math
Class Matrix
java.lang.Object
pal.math.Matrix
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
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetAppendedHorizontally
(Matrix other) getAppendedVertically
(Matrix other) final int
Obtains the inverse of a matrix by appending identity and doing row reduction.Cloningfinal Matrix
getMultiplied
(double scale) final Matrix
getMultiplied
(Matrix other) Multiply as in [this][other]Peforms a simple row reduction tramsformationgetSubsetColumns
(int startColumn, int numberToKeep) Returns a new Matrix that is formed from a subset of the colums of this matrixfinal Matrix
final double
getValue
(int row, int col) final int
getWidth()
final boolean
isSquare()
final void
multiply
(double scale) void
final void
setValue
(int row, int col, double value) double[]
toArray()
toString()
final void
-
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
- Returns:
- a new Matrix that is this matrix with other appended on the end (eg [this | other ])
-
getAppendedVertically
- Returns:
- a new Matrix that is this matrix with other appended on the bottom (eg [this / other ]
-
getSubsetColumns
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
-
multiply
public final void multiply(double scale) -
getMultiplied
Multiply as in [this][other] -
getMultiplied
-
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
Peforms a simple row reduction tramsformation- Returns:
- A row reduced version of this matrix
-
getMatrixCopy
Cloning- Returns:
- an exact copy of this matrix
-
toString
-