public class Matrix
extends java.lang.Object
| Constructor and Description |
|---|
Matrix(int dimension)
create a square matrix initialized to the identity
|
Matrix(int rows,
int cols)
create a matrix of any dimensions initialized to all zeroes.
|
Matrix(Matrix M)
Creates a matrix of a matrix...a copy
|
| Modifier and Type | Method and Description |
|---|---|
Matrix |
add(Matrix M2)
Adds two matrices together
|
static void |
add(Matrix r1,
double a)
Adds a constant to each element of this matrix
|
static Matrix |
add(Matrix M1,
Matrix M2)
Static method to add any two matrices
|
double |
cell(int i,
int j)
return the value in this matrix located at the ith row and jth column
|
int |
cols()
Get the number of columns in this matrix
|
static double |
det(double d1,
double d2,
double d3,
double d4)
Solves the determinate of this 2x2 matrix
|
static Matrix |
inversMat3x3(Matrix in)
Given a 3 x 3 matrix and using Determinats to solve for inverse
|
Matrix |
mult(double a)
scales a matrix, but does not destroy the content of the original
|
Matrix |
mult(Matrix M2)
Multiplies 2 matrixes together
|
static Matrix |
mult(Matrix M1,
Matrix M2)
multiplies two matrixes together
None Destructive
|
void |
multSelf(double a)
Scalar multiply in place
|
static double[] |
multVec(Matrix A,
double[] x)
Performs Ax multiplication
|
void |
print()
Prints the content of a matrix to standard out
|
void |
replace(Matrix M)
copy each cell from M to this.data
|
int |
rows()
Gets the number of rows in this matrix
|
void |
setCell(int i,
int j,
double value)
set the value of the cell at the ith row and jth column to value
|
Matrix |
subtract(Matrix M2)
Subtracts a matrix from this
|
static Matrix |
subtract(Matrix M1,
Matrix M2)
static Subtraces M2 from M1 5 = 8 - 3
|
static Matrix |
transpose(Matrix in)
Makes a transpose of the input matrix
|
public Matrix(int dimension)
dimension - - size to make a square matrixpublic Matrix(int rows,
int cols)
rows - cols - public Matrix(Matrix M) throws MatrixException
M - - matrix to copyMatrixExceptionpublic void replace(Matrix M) throws MatrixException
Replaces the value of this...destructive copy
to just get a copy of a matrix
Matrix mm33 is a matrix initialized to some value
Matrix inv = Matrix.inverseMxM(mm33);
This makes a copy of mm33 into inv. mm33 is not altered in this process.
M - - matrix to copyMatrixExceptionpublic int cols()
public int rows()
public double cell(int i,
int j)
throws MatrixException
Should have made this getCell, but I got too far along to make all the changes....
i - - rowj - - columnMatrixExceptionpublic void setCell(int i,
int j,
double value)
throws MatrixException
i - - rowj - - columnvalue - - the double to put in the cell (i,j)MatrixExceptionpublic Matrix add(Matrix M2) throws MatrixException
non-destructive
M2 - - what to add to thisMatrixExceptionpublic static void add(Matrix r1, double a) throws java.lang.Exception
r1 - - the matrix to receve the additiona - - the vlaue to ad to each cell of the matrixjava.lang.Exceptionpublic static Matrix add(Matrix M1, Matrix M2) throws MatrixException
M1 - M2 - MatrixExceptionpublic Matrix subtract(Matrix M2) throws MatrixException
non-destructive
M2 - MatrixExceptionpublic static Matrix subtract(Matrix M1, Matrix M2) throws MatrixException
M1 - - subtraced from matrix (the 8 in the above)M2 - - what is subtracte (the 3 in the above)MatrixExceptionpublic Matrix mult(double a) throws MatrixException
Non-destructive multiply
a - - the scalarMatrixExceptionpublic static Matrix transpose(Matrix in) throws MatrixException
rows become columns
Row 1 is now column 1
Row 2 is now column 2
Row n is now column n
in - - input matrixMatrixExceptionpublic static double[] multVec(Matrix A, double[] x) throws MatrixException
A - x - MatrixExceptionpublic void multSelf(double a)
Destructive multiply
a - public Matrix mult(Matrix M2) throws MatrixException
3x1 * 1x3 = 3x3
None Destructive
M2 - MatrixExceptionpublic static Matrix mult(Matrix M1, Matrix M2) throws MatrixException
M1 - left hand sideM2 - right hand sideMatrixExceptionpublic void print()
throws MatrixException
MatrixExceptionpublic static Matrix inversMat3x3(Matrix in) throws MatrixException
in - - input 3x3 matrixMatrixExceptionpublic static double det(double d1,
double d2,
double d3,
double d4)
d1 - - a11d2 - - a12d3 - - a21d4 - - a22