phelps.math
Class Matrix
public
class
Matrix
extends Object
Matrix manipulations: add, multiply, invert, transpose, determinant, Gauss-Jordan, simplex.
- construction and getters/setters: Matrix, Matrix, Matrix, Matrix, Matrix, equals
- one-matrix operations: transpose, invert, determinant
- two-matrix operations: add, Matrix, multiply,
- solve as system of equations: Matrix, Matrix
Version: $Revision: 1.6 $ $Date: 2003/02/06 06:56:10 $
See Also: "Introductory Linear Algebra with Applications, by John W. Brown and Donald R. Sherbert"
Constructor Summary |
| Matrix(int rows, int cols) Create a new matrix of the indicated number of m rows and columns. |
| Matrix(double[][] x) |
| Matrix(Matrix m) Create a new Matrix by copying (not sharing) the content of the one passed in. |
Method Summary |
Matrix | add(Matrix x)
Return new matrix that is sum of this and passed matrix.
|
double | determinant() Return the determinant of the matrix. |
boolean | equals(Object o) |
double | get(int row, int col) |
int | getCols() |
int | getRows() |
int | hashCode() |
Matrix | invert()
Returns new matrix that is the inverse.
|
double[] | maximize(double[] maximize)
Treat matrix as a system of equations and maximize the passed program with the Simplex method.
|
Matrix | multiply(double s)
Return new matrix that is result of multiplying each element by the scalar s. |
Matrix | multiply(Matrix x)
Return new matrix that is product of this and passed matrix. |
void | set(int row, int col, double val) |
double[] | solveGaussJordan(int vars)
Treat the m x n matrix as a system of m equations in m unknowns,
with the first m of n columns as coefficients, and
the remaining n-m columns (typically n-m == 1) as constants.
|
Matrix | transpose()
Return a new matrix that is the transpose of this one. |
public Matrix(int rows, int cols)
Create a new matrix of the indicated number of m rows and columns.
public Matrix(double[][] x)
Create a new Matrix by copying (not sharing) the content of the one passed in.
Return new matrix that is sum of this and passed matrix.
Matrices must have same dimensions.
Throws: IllegalArgumentException if passed matrix is of different dimension.
public double determinant()
Return the determinant of the matrix.
public boolean equals(Object o)
public double get(int row, int col)
public int getCols()
Returns: number of columns in matrix
public int getRows()
Returns: number of rows in matrix
public int hashCode()
Returns new matrix that is the inverse.
Subsequently multiplying this matrix by its inverse yields an identity matrix.
Throws: IllegalStateException if matrix is not invertable.
public double[] maximize(double[] maximize)
Treat matrix as a system of equations and maximize the passed program with the Simplex method.
Returns vector that is the solution (which is the same as the first row of the mutated matrix).
If maximum is unbounded, null is return.
Returns: values for the variables in [0..vars-1] and maximum obtained at these settings in [vars].
public
Matrix multiply(double s)
Return new matrix that is result of multiplying each element by the scalar s.
Return new matrix that is product of this and passed matrix.
Throws: IllegalArgumentException if passed matrix is of different dimension.
public void set(int row, int col, double val)
public double[] solveGaussJordan(int vars)
Treat the m x n matrix as a system of m equations in m unknowns,
with the first m of n columns as coefficients, and
the remaining n-m columns (typically n-m == 1) as constants.
The resulting mutated matrix reports the solution such that the first variable equals the value get(0, m+1), the second at get(1, m+1), and so on.
If there were multiple equations with the same coeffients but different constants, their results are available at get(0, m+2), get(1, m+2), and so on.
The first (and typically only) solution vector is also the method's return value.
If underdetermined....
Return a new matrix that is the transpose of this one.