|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.nps.moves.deadreckoning.utils.Matrix
public class Matrix
A class that performs some basic Matrix manipulations, stopping short of Eigenvectors, Single Value Decomposition, LU, and other more advaced manipulations.
Constructor Summary | |
---|---|
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 |
Method Summary | |
---|---|
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 |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
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 copy
MatrixException
Method Detail |
---|
public 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 copy
MatrixException
public 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
- - column
MatrixException
public void setCell(int i, int j, double value) throws MatrixException
i
- - rowj
- - columnvalue
- - the double to put in the cell (i,j)
MatrixException
public Matrix add(Matrix M2) throws MatrixException
non-destructive
M2
- - what to add to this
MatrixException
public 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 matrix
java.lang.Exception
public static Matrix add(Matrix M1, Matrix M2) throws MatrixException
M1
- M2
-
MatrixException
public Matrix subtract(Matrix M2) throws MatrixException
non-destructive
M2
-
MatrixException
public 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)
MatrixException
public Matrix mult(double a) throws MatrixException
Non-destructive multiply
a
- - the scalar
MatrixException
public 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 matrix
MatrixException
public static double[] multVec(Matrix A, double[] x) throws MatrixException
A
- x
-
MatrixException
public void multSelf(double a)
Destructive multiply
a
- public Matrix mult(Matrix M2) throws MatrixException
3x1 * 1x3 = 3x3
None Destructive
M2
-
MatrixException
public static Matrix mult(Matrix M1, Matrix M2) throws MatrixException
M1
- left hand sideM2
- right hand side
MatrixException
public void print() throws MatrixException
MatrixException
public static Matrix inversMat3x3(Matrix in) throws MatrixException
in
- - input 3x3 matrix
MatrixException
public static double det(double d1, double d2, double d3, double d4)
d1
- - a11d2
- - a12d3
- - a21d4
- - a22
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |