|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.vecmath.GMatrix javax.robotics.vecmath.Matrix
public class Matrix
A double precision, general, dynamically-resizable, two-dimensional matrix class. Row and column numbering begins with zero. The representation is row major. This class extends printing functionality of GMatrix class
Field Summary | |
---|---|
static short |
DEFINITE_NEGATIVE
Type of matrix. |
static short |
DEFINITE_POSITIVE
Type of matrix. |
static short |
SEMIDEFINITE_NEGATIVE
Type of matrix. |
static short |
SEMIDEFINITE_POSITIVE
Type of matrix. |
Constructor Summary | |
---|---|
Matrix(javax.vecmath.GMatrix matrix)
Constructs a new matrix with the same values as the GMatrix parameter. |
|
Matrix(int n)
Constructs an n by n identity matrix. |
|
Matrix(int n,
double[] matrix)
Constructs an n by n square matrix initialized to the values in the matrix array. |
|
Matrix(int nRow,
int nCol)
Constructs an nRow by NCol identity matrix. |
|
Matrix(int nRow,
int nCol,
double[] matrix)
Constructs an nRow by nCol matrix initialized to the values in the matrix array. |
|
Matrix(Matrix matrix)
Constructs a new matrix with the same values as the Matrix parameter. |
Method Summary | |
---|---|
Matrix |
arrayLeftDivide(Matrix B)
Element-by-element left division, C = this. |
Matrix |
arrayLeftDivideEquals(Matrix B)
Element-by-element left division in place, this = this. |
Matrix |
arrayRightDivide(Matrix B)
Element-by-element right division, C = this. |
Matrix |
arrayRightDivideEquals(Matrix B)
Element-by-element right division in place, this = this. |
static short |
checkEigenValue(RVector d)
Check the eigenvalues. |
RVector |
eig()
Eigenvalues of a nxn real matrix. |
void |
eig(Matrix D,
Matrix V)
Eigenvalues and eigenvectors of a nxn real matrix. |
void |
eig(Matrix D,
Matrix V,
RVector d,
RVector e)
Eigenvalues and eigenvectors of a nxn real matrix. |
void |
eig(RVector d)
Eigenvalues of a nxn real matrix. |
void |
get(double[] matrix)
Gets this matrix as mono dimensional array |
void |
get(double[][] matrix)
Gets this matrix as bi-dimensional array |
RVector |
getDiagonal()
Gets main diagonal of this matrix. |
void |
getSubMatrix(int startRow,
int endRow,
int startCol,
int endCol,
Matrix M)
Gets sub matrix from this Matrix. |
Matrix |
inverse()
Computes inverse or pseudoinverse of this matrix |
Matrix |
inverse(double eps,
double lambdaMax)
Computes Damped Least Square inverse of this matrix using SVD decomposition. |
boolean |
isSymmetric()
Check if this matrix is symmetric |
Matrix |
lyap(Matrix C)
Computes the solution of Lyapunov equation using eigenvalue decomposition. |
void |
mul(DMatrix D)
Sets the value of this matrix to the result of multiplying itself with diagonal matrix D (this = this * D). |
void |
printf()
Prints to standard out |
void |
printf(java.io.PrintStream out)
Prints to PrintStream |
void |
printf(java.io.PrintStream out,
java.lang.String format)
Prints to PrintStream according to the format string |
void |
printf(java.lang.String format)
Prints to standard out according to the format string. |
Matrix |
pseudoInverse()
Computes pseudo inverse of this matrix using SVD decomposition. |
void |
set(double[][] matrix)
Sets this matrix from bi-dimensional array |
void |
setDiagonal(RVector diag)
Sets the diagonal of this matrix. |
void |
setOnes()
Sets all elements of this matrix to one |
void |
splitColumns(double[]... v)
Splits columns of this matrix in multiple arrays. |
void |
splitColumns(RVector... v)
Splits columns of this matrix in multiple vectors. |
void |
splitRows(double[]... v)
Splits rows of this matrix in multiple arrays. |
void |
splitRows(RVector... v)
Splits rows of this matrix in multiple vectors. |
int |
svd(Matrix Q,
Matrix U,
Matrix V)
Finds Singular Values Decomposition SVD of this matrix. |
int |
svd(RVector s)
Finds the singular value of this matrix. |
java.lang.String |
toString()
Returns a string that contains the values of this Matrix. |
java.lang.String |
toString(java.lang.String format)
Returns a string that contains the values of this Matrix, according to the format string |
Methods inherited from class javax.vecmath.GMatrix |
---|
add, add, clone, copySubMatrix, epsilonEquals, epsilonEquals, equals, equals, get, get, get, get, get, getColumn, getColumn, getElement, getNumCol, getNumRow, getRow, getRow, hashCode, identityMinus, invert, invert, LUD, mul, mul, mul, mulTransposeBoth, mulTransposeLeft, mulTransposeRight, negate, negate, set, set, set, set, set, set, setColumn, setColumn, setElement, setIdentity, setRow, setRow, setScale, setSize, setZero, sub, sub, SVD, trace, transpose, transpose |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final short SEMIDEFINITE_NEGATIVE
eig(Matrix, Matrix, RVector, RVector)
,
Constant Field Valuespublic static final short DEFINITE_NEGATIVE
eig(Matrix, Matrix, RVector, RVector)
,
Constant Field Valuespublic static final short SEMIDEFINITE_POSITIVE
eig(Matrix, Matrix, RVector, RVector)
,
Constant Field Valuespublic static final short DEFINITE_POSITIVE
eig(Matrix, Matrix, RVector, RVector)
,
Constant Field ValuesConstructor Detail |
---|
public Matrix(javax.vecmath.GMatrix matrix)
matrix
- the source matrixpublic Matrix(Matrix matrix)
matrix
- the source matrixpublic Matrix(int n)
n
- number of rows and columns in this matrix.public Matrix(int nRow, int nCol)
nRow
- number of rows in this matrix.nCol
- number of columns in this matrix.public Matrix(int n, double[] matrix)
n
- number of rows and columns in this matrix.matrix
- the array that specifies a matrix in row major fashionpublic Matrix(int nRow, int nCol, double[] matrix)
nRow
- number of rows in this matrix.nCol
- number of columns in this matrix.matrix
- the array that specifies a matrix in row major fashionMethod Detail |
---|
public void printf()
public void printf(java.lang.String format)
The format specifiers for numeric types have the following syntax:
%[width][.precision]conversion
width
is a non-negative decimal
integer indicating the minimum number of characters to be written to the
output. precision
is a non-negative
decimal integer usually used to restrict the number of characters. The
specific behavior depends on the conversion. conversion
is a character
indicating how the argument should be formatted. The set of valid
conversions for a given argument depends on the argument's data type.
Example: v.printf("%5.3f");
format
- The format stringPrintStream.format(java.lang.String, java.lang.Object[])
public void printf(java.io.PrintStream out)
PrintStream
out
- The PrintStream
object.public void printf(java.io.PrintStream out, java.lang.String format)
PrintStream
according to the format string
out
- The PrintStream
object.format
- The format string.printf(String)
public java.lang.String toString()
toString
in class javax.vecmath.GMatrix
public java.lang.String toString(java.lang.String format)
format
- The format string
printf(String)
public int svd(RVector s)
Author: G. Jungman, Java version: Carmine Lia
Algorithm due to J.C. Nash, Compact Numerical Methods for Computers (New York: Wiley and Sons, 1979), chapter 3. See also Algorithm 4.1 in James Demmel, Kresimir Veselic, "Jacobi's Method is more accurate than QR", Lapack Working Note 15 (LAWN15), October 1989. Available from netlib. http://netlib.org/lapack/ in the lawns or lawnspdf directories
Based on code by Arthur Kosowsky, Rutgers University kosowsky@physics.rutgers.edu
Another relevant paper is, P.P.M. De Rijk, "A One-Sided Jacobi Algorithm for computing the singular value decomposition on a vector computer", SIAM Journal of Scientific and Statistical Computing, Vol 10, No 2, pp 359-371, March 1989.
s
- RVector of n singular values
public int svd(Matrix Q, Matrix U, Matrix V)
Factorise this M x N matrix, this = U Q V^T
where U is a column-orthogonal M x N matrix (U^T U = I), Q is a diagonal
N x N matrix, and V is an N x N orthogonal matrix (V^T V = V V^T = I).
Q
- the n x n diagonal matrix of singular valuesU
- the column-orthogonal m x n matrixV
- the orthogonal n x n matrix
SingularValueDecomposition
public void eig(Matrix D, Matrix V)
D
- the nxn block diagonal eigenvalue matrixV
- the nxn eigenvector matrixEigenvalueDecomposition
public void eig(Matrix D, Matrix V, RVector d, RVector e)
D
- the nxn block diagonal eigenvalue matrixV
- the nxn eigenvector matrixd
- the real part of the eigenvaluese
- the imaginary parts of the eigenvaluesEigenvalueDecomposition
public void eig(RVector d)
d
- the real part of the eigenvaluesEigenvalueDecomposition
public RVector eig()
EigenvalueDecomposition
public static short checkEigenValue(RVector d)
d
- the vector of real part of eigenvalues.
DEFINITE_NEGATIVE
,
DEFINITE_POSITIVE
,
SEMIDEFINITE_NEGATIVE
,
SEMIDEFINITE_POSITIVE
public Matrix pseudoInverse()
public Matrix inverse(double eps, double lambdaMax)
A-1 = AT*(A*AT + λ2*I)-1 where λ2 is the damped factor equals 1 - (σr/ε)*λ2max if σr< ε, equals 0 if σr≥ ε; σr is the smallest not null singular value.
eps
- the area of singular region.lambdaMax
- the maximum damped factor.
public Matrix inverse()
public Matrix lyap(Matrix C)
A*X + X*A' = -C
where the matrix A is this matrix,
the matrix X is the solution and C is the input matrix. Both the matrices
must be square with same dimensions.
Warning! the function fail if the eigenvalue of A are complex.
C
- input matrix of equation
public void setOnes()
public RVector getDiagonal()
public void setDiagonal(RVector diag)
diag
- elements to be placedpublic void get(double[] matrix)
matrix
- the arraypublic void get(double[][] matrix)
matrix
- the array copiedpublic void set(double[][] matrix)
matrix
- the source arraypublic void getSubMatrix(int startRow, int endRow, int startCol, int endCol, Matrix M)
startRow
- endRow
- startCol
- endCol
- M
- the sub matrixpublic Matrix arrayRightDivide(Matrix B)
B
- another matrix
public Matrix arrayRightDivideEquals(Matrix B)
B
- another matrix
public Matrix arrayLeftDivide(Matrix B)
B
- another matrix
public Matrix arrayLeftDivideEquals(Matrix B)
B
- another matrix
public boolean isSymmetric()
public void mul(DMatrix D)
D
- the input diagonal matrix.public void splitColumns(RVector... v)
v
- the destination array of vectorspublic void splitColumns(double[]... v)
v
- the destination array of arrayspublic void splitRows(RVector... v)
v
- the destination array of vectorspublic void splitRows(double[]... v)
v
- the destination array of arrays
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |