All Packages Class Hierarchy This Package Previous Next Index
Class java.vecmath.GMatrix
java.lang.Object
|
+----java.vecmath.GMatrix
- public class GMatrix
- extends Object
A double precision, general, real, and dynamically resizeable two
dimensional N x M matrix class. Row and column numbering begins
with zero. The representation is row major.
-
GMatrix(GMatrix)
-
Constructs a new GMatrix and copies the initial values
from the parameter matrix.
-
GMatrix(int, int)
- Constructs an nRow by NCol identity matrix.
-
GMatrix(int, int, double[])
-
Constructs an nRow by nCol matrix initialized to the values
in the matrix array.
-
add(GMatrix)
- Sets the value of this matrix to sum of itself and matrix m1.
-
add(GMatrix, GMatrix)
- Sets the value of this matrix to the matrix sum of matrices m1 and m2.
-
copySubMatrix(int, int, int, int, int, int, GMatrix)
- Copies a sub-matrix derived from this matrix into the target matrix.
-
epsilonEquals(GMatrix, float)
- 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.
-
equals(GMatrix)
- Returns true if all of the data members of GMatrix m1 are
equal to the corresponding data members in this GMatrix.
-
get(GMatrix)
- Places the values in the this GMatrix into the matrix m1;
m1 should be at least as large as this GMatrix.
-
get(Matrix3d)
- Places the values in the upper 3x3 of this GMatrix into
the matrix m1.
-
get(Matrix3f)
- Places the values in the upper 3x3 of this GMatrix into
the matrix m1.
-
get(Matrix4d)
- Places the values in the upper 4x4 of this GMatrix into
the matrix m1.
-
get(Matrix4f)
- Places the values in the upper 4x4 of this GMatrix into
the matrix m1.
-
getColumn(int, double[])
- Places the values of the specified column into the array parameter.
-
getColumn(int, GVector)
- Places the values of the specified column into the vector parameter.
-
getElement(int, int)
- Retrieves the value at the specified row and column of this matrix.
-
getNumCol()
- Returns the number of colmuns in this matrix.
-
getNumRow()
- Returns the number of rows in this matrix.
-
getRow(int, double[])
- Places the values of the specified row into the array parameter.
-
getRow(int, GVector)
- Places the values of the specified row into the vector parameter.
-
hashCode()
- Returns a hash number based on the data values in this
object.
-
identityMinus()
- Subtracts this matrix from the identity matrix and puts the values
back into this (this = I - this).
-
invert()
- Inverts this matrix in place.
-
invert(GMatrix)
- Inverts matrix m1 and places the new values into this matrix.
-
LUD(GMatrix, GVector)
- LU Decomposition; this matrix must be a square matrix; the
LU GMatrix parameter must be the same size as this matrix.
-
mul(GMatrix)
- Sets the value of this matrix to the result of multiplying itself
with matrix m1 (this = this * m1).
-
mul(GMatrix, GMatrix)
- Sets the value of this matrix to the result of multiplying
the two argument matrices together (this = m1 * m2).
-
mulTransposeBoth(GMatrix, GMatrix)
- Multiplies the transpose of matrix m1 times the transpose of matrix
m2, and places the result into this.
-
mulTransposeLeft(GMatrix, GMatrix)
-
Multiplies the transpose of matrix m1 times matrix m2, and
places the result into this.
-
mulTransposeRight(GMatrix, GMatrix)
-
Multiplies matrix m1 times the transpose of matrix m2, and
places the result into this.
-
negate()
-
Negates the value of this matrix: this = -this.
-
negate(GMatrix)
- Sets the value of this matrix equal to the negation of
of the GMatrix parameter.
-
set(double[])
- Sets the value of this matrix to the values found in the array parameter.
-
set(GMatrix)
- Sets the value of this matrix to the values found in matrix m1.
-
set(Matrix3d)
- Sets the value of this matrix to that of the Matrix3d provided.
-
set(Matrix3f)
- Sets the value of this matrix to that of the Matrix3f provided.
-
set(Matrix4d)
-
Sets the value of this matrix to that of the Matrix4d provided.
-
set(Matrix4f)
-
Sets the value of this matrix to that of the Matrix4f provided.
-
setColumn(int, double[])
- Copy the values from the array into the specified column of this
matrix.
-
setColumn(int, GVector)
- Copy the values from the vector into the specified column of this
matrix.
-
setElement(int, int, double)
-
Modifies the value at the specified row and column of this matrix.
-
setIdentity()
- Sets this GMatrix to the identity matrix.
-
setRow(int, double[])
- Copy the values from the array into the specified row of this
matrix.
-
setRow(int, GVector)
- Copy the values from the vector into the specified row of this
matrix.
-
setScale(double)
-
Sets this matrix to a uniform scale matrix; all of the
values are reset.
-
setSize(int, int)
- Changes the size of this matrix dynamically.
-
setZero()
- Sets all the values in this matrix to zero.
-
sub(GMatrix)
- Sets the value of this matrix to the matrix difference of itself
and matrix m1 (this = this - m1).
-
sub(GMatrix, GMatrix)
- Sets the value of this matrix to the matrix difference
of matrices m1 and m2 (this = m1 - m2).
-
SVD(GMatrix, GMatrix, GMatrix)
- 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.
-
toString()
- Returns a string that contains the values of this GMatrix.
-
trace()
- Returns the trace of this matrix.
-
transpose()
- Transposes this matrix in place.
-
transpose(GMatrix)
- Places the matrix values of the transpose of matrix m1 into this matrix.
GMatrix
public GMatrix(int nRow,
int nCol)
- Constructs an nRow by NCol identity matrix.
Note that even though row and column numbering begins with
zero, nRow and nCol will be one larger than the maximum
possible matrix index values.
- Parameters:
- nRow - number of rows in this matrix.
- nCol - number of columns in this matrix.
GMatrix
public GMatrix(int nRow,
int nCol,
double matrix[])
- Constructs an nRow by nCol matrix initialized to the values
in the matrix array. The array values are copied in one row at
a time in row major fashion. The array should be at least
nRow*nCol in length.
Note that even though row and column numbering begins with
zero, nRow and nCol will be one larger than the maximum
possible matrix index values.
- Parameters:
- 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 fashion
GMatrix
public GMatrix(GMatrix matrix)
- Constructs a new GMatrix and copies the initial values
from the parameter matrix.
- Parameters:
- matrix - the source of the initial values of the new GMatrix
mul
public final void mul(GMatrix m1)
- Sets the value of this matrix to the result of multiplying itself
with matrix m1 (this = this * m1).
- Parameters:
- m1 - the other matrix
mul
public final 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).
- Parameters:
- m1 - the first matrix
- m2 - the second matrix
add
public final void add(GMatrix m1)
- Sets the value of this matrix to sum of itself and matrix m1.
- Parameters:
- m1 - the other matrix
add
public final void add(GMatrix m1,
GMatrix m2)
- Sets the value of this matrix to the matrix sum of matrices m1 and m2.
- Parameters:
- m1 - the first matrix
- m2 - the second matrix
sub
public final void sub(GMatrix m1)
- Sets the value of this matrix to the matrix difference of itself
and matrix m1 (this = this - m1).
- Parameters:
- m1 - the other matrix
sub
public final void sub(GMatrix m1,
GMatrix m2)
- Sets the value of this matrix to the matrix difference
of matrices m1 and m2 (this = m1 - m2).
- Parameters:
- m1 - the first matrix
- m2 - the second matrix
negate
public final void negate()
- Negates the value of this matrix: this = -this.
negate
public final void negate(GMatrix m1)
- Sets the value of this matrix equal to the negation of
of the GMatrix parameter.
- Parameters:
- m1 - The source matrix
setIdentity
public final void setIdentity()
- Sets this GMatrix to the identity matrix.
setZero
public final void setZero()
- Sets all the values in this matrix to zero.
identityMinus
public final void identityMinus()
- Subtracts this matrix from the identity matrix and puts the values
back into this (this = I - this).
invert
public final void invert()
- Inverts this matrix in place.
invert
public final void invert(GMatrix m1)
- Inverts matrix m1 and places the new values into this matrix. Matrix
m1 is not modified.
- Parameters:
- m1 - the matrix to be inverted
copySubMatrix
public final 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.
The upper left of the sub-matrix is located at (rowSource, colSource);
the lower right of the sub-matrix is located at
(lastRowSource,lastColSource). The sub-matrix is copied into the
the target matrix starting at (rowDest, colDest).
- Parameters:
- rowSource - the top-most row of the sub-matrix
- colSource - the left-most column of the sub-matrix
- numRow - the number of rows in the sub-matrix
- numCol - the number of columns in the sub-matrix
- rowDest - the top-most row of the position of the copied sub-matrix
within the target matrix
- colDest - the left-most column of the position of the copied sub-matrix
within the target matrix
- target - the matrix into which the sub-matrix will be copied
setSize
public final void setSize(int nRow,
int nCol)
- Changes the size of this matrix dynamically. If the size is increased
no data values will be lost. If the size is decreased, only those data
values whose matrix positions were eliminated will be lost.
- Parameters:
- nRow - number of desired rows in this matrix
- nCol - number of desired columns in this matrix
set
public final void set(double matrix[])
- Sets the value of this matrix to the values found in the array parameter.
The values are copied in one row at a time, in row major
fashion. The array should be at least equal in length to
the number of matrix rows times the number of matrix columns
in this matrix.
- Parameters:
- matrix - the row major source array
set
public final void set(Matrix3f m1)
- Sets the value of this matrix to that of the Matrix3f provided.
- Parameters:
- m1 - the matrix
set
public final void set(Matrix3d m1)
- Sets the value of this matrix to that of the Matrix3d provided.
- Parameters:
- m1 - the matrix
set
public final void set(Matrix4f m1)
- Sets the value of this matrix to that of the Matrix4f provided.
- Parameters:
- m1 - the matrix
set
public final void set(Matrix4d m1)
- Sets the value of this matrix to that of the Matrix4d provided.
- Parameters:
- m1 - the matrix
set
public final void set(GMatrix m1)
- Sets the value of this matrix to the values found in matrix m1.
- Parameters:
- m1 - the source matrix
getNumRow
public final int getNumRow()
- Returns the number of rows in this matrix.
- Returns:
- number of rows in this matrix
getNumCol
public final int getNumCol()
- Returns the number of colmuns in this matrix.
- Returns:
- number of columns in this matrix
getElement
public final double getElement(int row,
int column)
- Retrieves the value at the specified row and column of this matrix.
- Parameters:
- row - the row number to be retrieved (zero indexed)
- column - the column number to be retrieved (zero indexed)
- Returns:
- the value at the indexed element
setElement
public final void setElement(int row,
int column,
double value)
- Modifies the value at the specified row and column of this matrix.
- Parameters:
- row - the row number to be modified (zero indexed)
- column - the column number to be modified (zero indexed)
- value - the new matrix element value
getRow
public final void getRow(int row,
double array[])
- Places the values of the specified row into the array parameter.
- Parameters:
- row - the target row number
- array - the array into which the row values will be placed
getRow
public final void getRow(int row,
GVector vector)
- Places the values of the specified row into the vector parameter.
- Parameters:
- row - the target row number
- vector - the vector into which the row values will be placed
getColumn
public final void getColumn(int col,
double array[])
- Places the values of the specified column into the array parameter.
- Parameters:
- col - the target column number
- array - the array into which the column values will be placed
getColumn
public final void getColumn(int col,
GVector vector)
- Places the values of the specified column into the vector parameter.
- Parameters:
- col - the target column number
- vector - the vector into which the column values will be placed
get
public final void get(Matrix3d m1)
- Places the values in the upper 3x3 of this GMatrix into
the matrix m1.
- Parameters:
- m1 - The matrix that will hold the new values
get
public final void get(Matrix3f m1)
- Places the values in the upper 3x3 of this GMatrix into
the matrix m1.
- Parameters:
- m1 - The matrix that will hold the new values
get
public final void get(Matrix4d m1)
- Places the values in the upper 4x4 of this GMatrix into
the matrix m1.
- Parameters:
- m1 - The matrix that will hold the new values
get
public final void get(Matrix4f m1)
- Places the values in the upper 4x4 of this GMatrix into
the matrix m1.
- Parameters:
- m1 - The matrix that will hold the new values
get
public final 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.
- Parameters:
- m1 - The matrix that will hold the new values
setRow
public final void setRow(int row,
double array[])
- Copy the values from the array into the specified row of this
matrix.
- Parameters:
- row - the row of this matrix into which the array values
will be copied.
- array - the source array
setRow
public final void setRow(int row,
GVector vector)
- Copy the values from the vector into the specified row of this
matrix.
- Parameters:
- row - the row of this matrix into which the array values
will be copied.
- vector - the source vector
setColumn
public final void setColumn(int col,
double array[])
- Copy the values from the array into the specified column of this
matrix.
- Parameters:
- col - the column of this matrix into which the array values
will be copied.
- array - the source array
setColumn
public final void setColumn(int col,
GVector vector)
- Copy the values from the vector into the specified column of this
matrix.
- Parameters:
- col - the column of this matrix into which the array values
will be copied.
- vector - the source vector
mulTransposeBoth
public final void mulTransposeBoth(GMatrix m1,
GMatrix m2)
- Multiplies the transpose of matrix m1 times the transpose of matrix
m2, and places the result into this.
- Parameters:
- m1 - The matrix on the left hand side of the multiplication
- m2 - The matrix on the right hand side of the multiplication
mulTransposeRight
public final void mulTransposeRight(GMatrix m1,
GMatrix m2)
- Multiplies matrix m1 times the transpose of matrix m2, and
places the result into this.
- Parameters:
- m1 - The matrix on the left hand side of the multiplication
- m2 - The matrix on the right hand side of the multiplication
mulTransposeLeft
public final void mulTransposeLeft(GMatrix m1,
GMatrix m2)
- Multiplies the transpose of matrix m1 times matrix m2, and
places the result into this.
- Parameters:
- m1 - The matrix on the left hand side of the multiplication
- m2 - The matrix on the right hand side of the multiplication
transpose
public final void transpose()
- Transposes this matrix in place.
transpose
public final void transpose(GMatrix m1)
- Places the matrix values of the transpose of matrix m1 into this matrix.
- Parameters:
- m1 - the matrix to be transposed (but not modified)
toString
public String toString()
- Returns a string that contains the values of this GMatrix.
- Returns:
- the String representation
- Overrides:
- toString in class Object
hashCode
public int hashCode()
- Returns a hash number based on the data values in this
object. Two different GMatrix objects with identical data values
(ie, returns true for equals(GMatrix) ) will return the same hash
number. Two objects with different data members may return the
same hash value, although this is not likely.
- Returns:
- the integer hash value
- Overrides:
- hashCode in class Object
equals
public 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.
- Parameters:
- m1 - The matrix with which the comparison is made.
- Returns:
- true or false
epsilonEquals
public boolean epsilonEquals(GMatrix m1,
float 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. The L-infinite
distance is equal to
MAX[i=0,1,2, . . .n ; j=0,1,2, . . .n ; abs(this.m(i,j) - m1.m(i,j)]
- Parameters:
- m1 - The matrix to be compared to this matrix
- epsilon - the threshold value
trace
public final double trace()
- Returns the trace of this matrix.
- Returns:
- the trace of this matrix
SVD
public final 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. Note
that the matrix V is output as V, and
not transpose(V). If this matrix is mxn, then U is mxm, W
is a diagonal matrix that is mxn, and V is nxn. Using the
notation W = diag(w), then the inverse of this matrix is:
inverse(this) = V*diag(1/w)*tranpose(U), where diag(1/w)
is the same matrix as W except that the reciprocal of each
of the diagonal components is used.
- Parameters:
- 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)
- Returns:
- The rank of this matrix.
LUD
public final int LUD(GMatrix LU,
GVector permutation)
- LU Decomposition; this matrix must be a square matrix; the
LU GMatrix parameter must be the same size as this matrix.
The matrix LU will be overwritten as the combination of a
lower diagonal and upper diagonal matrix decompostion of this
matrix; the diagonal
elements of L (unity) are not stored. The GVector parameter
records the row permutation effected by the partial pivoting,
and is used as a parameter to the GVector method LUDBackSolve
to solve sets of linear equations.
This method returns +/- 1 depending on whether the number
of row interchanges was even or odd, respectively.
- Parameters:
- LU - The matrix into which the lower and upper decompositions
will be placed.
- permutation - The row permutation effected by the partial
pivoting
- Returns:
- +-1 depending on whether the number of row interchanges
was even or odd respectively
setScale
public final void setScale(double scale)
- Sets this matrix to a uniform scale matrix; all of the
values are reset.
- Parameters:
- scale - The new scale value
All Packages Class Hierarchy This Package Previous Next Index