|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.vecmath.GMatrix
public class GMatrix
A double precision, general, dynamically-resizable, two-dimensional matrix class. Row and column numbering begins with zero. The representation is row major.
Field Summary | |
---|---|
private static boolean |
debug
|
private static double |
EPS
|
(package private) int |
nCol
|
(package private) int |
nRow
|
(package private) static long |
serialVersionUID
|
(package private) double[][] |
values
|
Constructor Summary | |
---|---|
GMatrix(GMatrix matrix)
Constructs a new GMatrix and copies the initial values from the parameter matrix. |
|
GMatrix(int nRow,
int nCol)
Constructs an nRow by NCol identity matrix. |
|
GMatrix(int nRow,
int nCol,
double[] matrix)
Constructs an nRow by nCol matrix initialized to the values in the matrix array. |
Method Summary | |
---|---|
void |
add(GMatrix m1)
Sets the value of this matrix to sum of itself and matrix m1. |
void |
add(GMatrix m1,
GMatrix m2)
Sets the value of this matrix to the matrix sum of matrices m1 and m2. |
private static void |
chase_across(double[] s,
double[] e,
int k,
GMatrix u)
|
private static void |
chase_up(double[] s,
double[] e,
int k,
GMatrix v)
|
private static void |
checkMatrix(GMatrix m)
|
java.lang.Object |
clone()
Creates a new object of the same class as this object. |
(package private) static int |
compute_2X2(double f,
double g,
double h,
double[] single_values,
double[] snl,
double[] csl,
double[] snr,
double[] csr,
int index)
|
(package private) static void |
compute_qr(int start,
int end,
double[] s,
double[] e,
GMatrix u,
GMatrix v)
|
(package private) static double |
compute_rot(double f,
double g,
double[] sin,
double[] cos)
|
(package private) static double |
compute_shift(double f,
double g,
double h)
|
(package private) static int |
computeSVD(GMatrix mat,
GMatrix U,
GMatrix W,
GMatrix V)
|
void |
copySubMatrix(int rowSource,
int colSource,
int numRow,
int numCol,
int rowDest,
int colDest,
GMatrix target)
Copies a sub-matrix derived from this matrix into the target matrix. |
(package private) static double |
d_sign(double a,
double b)
|
boolean |
epsilonEquals(GMatrix m1,
double epsilon)
Returns true if the L-infinite distance between this matrix and matrix m1 is less than or equal to the epsilon parameter, otherwise returns false. |
boolean |
epsilonEquals(GMatrix m1,
float epsilon)
Deprecated. Use epsilonEquals(GMatrix, double) instead |
boolean |
equals(GMatrix m1)
Returns true if all of the data members of GMatrix m1 are equal to the corresponding data members in this GMatrix. |
boolean |
equals(java.lang.Object o1)
Returns true if the Object o1 is of type GMatrix and all of the data members of o1 are equal to the corresponding data members in this GMatrix. |
void |
get(GMatrix m1)
Places the values in the this GMatrix into the matrix m1; m1 should be at least as large as this GMatrix. |
void |
get(Matrix3d m1)
Places the values in the upper 3x3 of this GMatrix into the matrix m1. |
void |
get(Matrix3f m1)
Places the values in the upper 3x3 of this GMatrix into the matrix m1. |
void |
get(Matrix4d m1)
Places the values in the upper 4x4 of this GMatrix into the matrix m1. |
void |
get(Matrix4f m1)
Places the values in the upper 4x4 of this GMatrix into the matrix m1. |
void |
getColumn(int col,
double[] array)
Places the values of the specified column into the array parameter. |
void |
getColumn(int col,
GVector vector)
Places the values of the specified column into the vector parameter. |
double |
getElement(int row,
int column)
Retrieves the value at the specified row and column of this matrix. |
int |
getNumCol()
Returns the number of colmuns in this matrix. |
int |
getNumRow()
Returns the number of rows in this matrix. |
void |
getRow(int row,
double[] array)
Places the values of the specified row into the array parameter. |
void |
getRow(int row,
GVector vector)
Places the values of the specified row into the vector parameter. |
int |
hashCode()
Returns a hash code value based on the data values in this object. |
void |
identityMinus()
Subtracts this matrix from the identity matrix and puts the values back into this (this = I - this). |
void |
invert()
Inverts this matrix in place. |
void |
invert(GMatrix m1)
Inverts matrix m1 and places the new values into this matrix. |
(package private) void |
invertGeneral(GMatrix m1)
General invert routine. |
(package private) static void |
luBacksubstitution(int dim,
double[] matrix1,
int[] row_perm,
double[] matrix2)
Solves a set of linear equations. |
int |
LUD(GMatrix LU,
GVector permutation)
LU Decomposition: this matrix must be a square matrix and the LU GMatrix parameter must be the same size as this matrix. |
(package private) static boolean |
luDecomposition(int dim,
double[] matrix0,
int[] row_perm,
int[] even_row_xchg)
Given a nxn array "matrix0", this function replaces it with the LU decomposition of a row-wise permutation of itself. |
(package private) static double |
max(double a,
double b)
|
(package private) static double |
min(double a,
double b)
|
void |
mul(GMatrix m1)
Sets the value of this matrix to the result of multiplying itself with matrix m1 (this = this * m1). |
void |
mul(GMatrix m1,
GMatrix m2)
Sets the value of this matrix to the result of multiplying the two argument matrices together (this = m1 * m2). |
void |
mul(GVector v1,
GVector v2)
Computes the outer product of the two vectors; multiplies the the first vector by the transpose of the second vector and places the matrix result into this matrix. |
void |
mulTransposeBoth(GMatrix m1,
GMatrix m2)
Multiplies the transpose of matrix m1 times the transpose of matrix m2, and places the result into this. |
void |
mulTransposeLeft(GMatrix m1,
GMatrix m2)
Multiplies the transpose of matrix m1 times matrix m2, and places the result into this. |
void |
mulTransposeRight(GMatrix m1,
GMatrix m2)
Multiplies matrix m1 times the transpose of matrix m2, and places the result into this. |
void |
negate()
Negates the value of this matrix: this = -this. |
void |
negate(GMatrix m1)
Sets the value of this matrix equal to the negation of of the GMatrix parameter. |
private static void |
print_m(GMatrix m,
GMatrix u,
GMatrix v)
|
private static void |
print_se(double[] s,
double[] e)
|
private static void |
print_svd(double[] s,
double[] e,
GMatrix u,
GMatrix v)
|
void |
set(double[] matrix)
Sets the value of this matrix to the values found in the array parameter. |
void |
set(GMatrix m1)
Sets the value of this matrix to the values found in matrix m1. |
void |
set(Matrix3d m1)
Sets the value of this matrix to that of the Matrix3d provided. |
void |
set(Matrix3f m1)
Sets the value of this matrix to that of the Matrix3f provided. |
void |
set(Matrix4d m1)
Sets the value of this matrix to that of the Matrix4d provided. |
void |
set(Matrix4f m1)
Sets the value of this matrix to that of the Matrix4f provided. |
void |
setColumn(int col,
double[] array)
Copy the values from the array into the specified column of this matrix. |
void |
setColumn(int col,
GVector vector)
Copy the values from the vector into the specified column of this matrix. |
void |
setElement(int row,
int column,
double value)
Modifies the value at the specified row and column of this matrix. |
void |
setIdentity()
Sets this GMatrix to the identity matrix. |
void |
setRow(int row,
double[] array)
Copy the values from the array into the specified row of this matrix. |
void |
setRow(int row,
GVector vector)
Copy the values from the vector into the specified row of this matrix. |
void |
setScale(double scale)
Sets this matrix to a uniform scale matrix; all of the values are reset. |
void |
setSize(int nRow,
int nCol)
Changes the size of this matrix dynamically. |
void |
setZero()
Sets all the values in this matrix to zero. |
void |
sub(GMatrix m1)
Sets the value of this matrix to the matrix difference of itself and matrix m1 (this = this - m1). |
void |
sub(GMatrix m1,
GMatrix m2)
Sets the value of this matrix to the matrix difference of matrices m1 and m2 (this = m1 - m2). |
int |
SVD(GMatrix U,
GMatrix W,
GMatrix V)
Finds the singular value decomposition (SVD) of this matrix such that this = U*W*transpose(V); and returns the rank of this matrix; the values of U,W,V are all overwritten. |
java.lang.String |
toString()
Returns a string that contains the values of this GMatrix. |
private static java.lang.String |
toString(GMatrix m)
|
double |
trace()
Returns the trace of this matrix. |
void |
transpose()
Transposes this matrix in place. |
void |
transpose(GMatrix m1)
Places the matrix values of the transpose of matrix m1 into this matrix. |
private static void |
update_u_split(int topr,
int bottomr,
GMatrix u,
double[] cosl,
double[] sinl,
GMatrix t,
GMatrix m)
|
private static void |
update_u(int index,
GMatrix u,
double[] cosl,
double[] sinl)
|
private static void |
update_v_split(int topr,
int bottomr,
GMatrix v,
double[] cosr,
double[] sinr,
GMatrix t,
GMatrix m)
|
private static void |
update_v(int index,
GMatrix v,
double[] cosr,
double[] sinr)
|
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
static final long serialVersionUID
private static final boolean debug
int nRow
int nCol
double[][] values
private static final double EPS
Constructor Detail |
---|
public GMatrix(int nRow, int nCol)
nRow
- number of rows in this matrix.nCol
- number of columns in this matrix.public GMatrix(int nRow, int nCol, double[] matrix)
nRow
- number of rows in this matrix.nCol
- number of columns in this matrix.matrix
- a 1D array that specifies a matrix in row major fashionpublic GMatrix(GMatrix matrix)
matrix
- the source of the initial values of the new GMatrixMethod Detail |
---|
public final void mul(GMatrix m1)
m1
- the other matrixpublic final void mul(GMatrix m1, GMatrix m2)
m1
- the first matrixm2
- the second matrixpublic final void mul(GVector v1, GVector v2)
v1
- the first vector, treated as a row vectorv2
- the second vector, treated as a column vectorpublic final void add(GMatrix m1)
m1
- the other matrixpublic final void add(GMatrix m1, GMatrix m2)
m1
- the first matrixm2
- the second matrixpublic final void sub(GMatrix m1)
m1
- the other matrixpublic final void sub(GMatrix m1, GMatrix m2)
m1
- the first matrixm2
- the second matrixpublic final void negate()
public final void negate(GMatrix m1)
m1
- The source matrixpublic final void setIdentity()
public final void setZero()
public final void identityMinus()
public final void invert()
public final void invert(GMatrix m1)
m1
- the matrix to be invertedpublic final void copySubMatrix(int rowSource, int colSource, int numRow, int numCol, int rowDest, int colDest, GMatrix target)
rowSource
- the top-most row of the sub-matrixcolSource
- the left-most column of the sub-matrixnumRow
- the number of rows in the sub-matrixnumCol
- the number of columns in the sub-matrixrowDest
- the top-most row of the position of the copied
sub-matrix within the target matrixcolDest
- the left-most column of the position of the copied
sub-matrix within the target matrixtarget
- the matrix into which the sub-matrix will be copiedpublic final void setSize(int nRow, int nCol)
nRow
- number of desired rows in this matrixnCol
- number of desired columns in this matrixpublic final void set(double[] matrix)
matrix
- the row major source arraypublic final void set(Matrix3f m1)
m1
- the matrixpublic final void set(Matrix3d m1)
m1
- the matrixpublic final void set(Matrix4f m1)
m1
- the matrixpublic final void set(Matrix4d m1)
m1
- the matrixpublic final void set(GMatrix m1)
m1
- the source matrixpublic final int getNumRow()
public final int getNumCol()
public final double getElement(int row, int column)
row
- the row number to be retrieved (zero indexed)column
- the column number to be retrieved (zero indexed)
public final void setElement(int row, int column, double value)
row
- the row number to be modified (zero indexed)column
- the column number to be modified (zero indexed)value
- the new matrix element valuepublic final void getRow(int row, double[] array)
row
- the target row numberarray
- the array into which the row values will be placedpublic final void getRow(int row, GVector vector)
row
- the target row numbervector
- the vector into which the row values will be placedpublic final void getColumn(int col, double[] array)
col
- the target column numberarray
- the array into which the column values will be placedpublic final void getColumn(int col, GVector vector)
col
- the target column numbervector
- the vector into which the column values will be placedpublic final void get(Matrix3d m1)
m1
- The matrix that will hold the new valuespublic final void get(Matrix3f m1)
m1
- The matrix that will hold the new valuespublic final void get(Matrix4d m1)
m1
- The matrix that will hold the new valuespublic final void get(Matrix4f m1)
m1
- The matrix that will hold the new valuespublic final void get(GMatrix m1)
m1
- The matrix that will hold the new valuespublic final void setRow(int row, double[] array)
row
- the row of this matrix into which the array values
will be copied.array
- the source arraypublic final void setRow(int row, GVector vector)
row
- the row of this matrix into which the array values
will be copiedvector
- the source vectorpublic final void setColumn(int col, double[] array)
col
- the column of this matrix into which the array values
will be copiedarray
- the source arraypublic final void setColumn(int col, GVector vector)
col
- the column of this matrix into which the array values
will be copiedvector
- the source vectorpublic final void mulTransposeBoth(GMatrix m1, GMatrix m2)
m1
- The matrix on the left hand side of the multiplicationm2
- The matrix on the right hand side of the multiplicationpublic final void mulTransposeRight(GMatrix m1, GMatrix m2)
m1
- The matrix on the left hand side of the multiplicationm2
- The matrix on the right hand side of the multiplicationpublic final void mulTransposeLeft(GMatrix m1, GMatrix m2)
m1
- The matrix on the left hand side of the multiplicationm2
- The matrix on the right hand side of the multiplicationpublic final void transpose()
public final void transpose(GMatrix m1)
m1
- the matrix to be transposed (but not modified)public java.lang.String toString()
toString
in class java.lang.Object
private static void checkMatrix(GMatrix m)
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(GMatrix m1)
m1
- The matrix with which the comparison is made.
public boolean equals(java.lang.Object o1)
equals
in class java.lang.Object
o1
- The object with which the comparison is made.
public boolean epsilonEquals(GMatrix m1, float epsilon)
public boolean epsilonEquals(GMatrix m1, double epsilon)
m1
- The matrix to be compared to this matrixepsilon
- the threshold valuepublic final double trace()
public final int SVD(GMatrix U, GMatrix W, GMatrix V)
U
- The computed U matrix in the equation this = U*W*transpose(V)W
- The computed W matrix in the equation this = U*W*transpose(V)V
- The computed V matrix in the equation this = U*W*transpose(V)
public final int LUD(GMatrix LU, GVector permutation)
LU
- The matrix into which the lower and upper decompositions
will be placed.permutation
- The row permutation effected by the partial
pivoting
public final void setScale(double scale)
scale
- The new scale valuefinal void invertGeneral(GMatrix m1)
static boolean luDecomposition(int dim, double[] matrix0, int[] row_perm, int[] even_row_xchg)
static void luBacksubstitution(int dim, double[] matrix1, int[] row_perm, double[] matrix2)
static int computeSVD(GMatrix mat, GMatrix U, GMatrix W, GMatrix V)
static void compute_qr(int start, int end, double[] s, double[] e, GMatrix u, GMatrix v)
private static void print_se(double[] s, double[] e)
private static void update_v(int index, GMatrix v, double[] cosr, double[] sinr)
private static void chase_up(double[] s, double[] e, int k, GMatrix v)
private static void chase_across(double[] s, double[] e, int k, GMatrix u)
private static void update_v_split(int topr, int bottomr, GMatrix v, double[] cosr, double[] sinr, GMatrix t, GMatrix m)
private static void update_u_split(int topr, int bottomr, GMatrix u, double[] cosl, double[] sinl, GMatrix t, GMatrix m)
private static void update_u(int index, GMatrix u, double[] cosl, double[] sinl)
private static void print_m(GMatrix m, GMatrix u, GMatrix v)
private static java.lang.String toString(GMatrix m)
private static void print_svd(double[] s, double[] e, GMatrix u, GMatrix v)
static double max(double a, double b)
static double min(double a, double b)
static double compute_shift(double f, double g, double h)
static int compute_2X2(double f, double g, double h, double[] single_values, double[] snl, double[] csl, double[] snr, double[] csr, int index)
static double compute_rot(double f, double g, double[] sin, double[] cos)
static double d_sign(double a, double b)
public java.lang.Object clone()
clone
in class java.lang.Object
java.lang.OutOfMemoryError
- if there is not enough memory.Cloneable
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |