|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmaspack.matrix.SVDecomposition
public class SVDecomposition
Constructs the singular value decomposition (SVD) of a matrix. This takes the
form
M = U S V'
where M is the original matrix, U and V are orthogonal matrices, V' indicates
the transpose of V, and S is a diagonal matrix. Once an SVD has been
constructed, it can be used to perform various computations related to M,
such as solving equations, computing the determinant, or estimating the
condition number.
Providing a separate class for the SVD allows an application to perform such decompositions repeatedly without having to reallocate temporary storage space.
Field Summary | |
---|---|
static int |
DEFAULT_ITERATION_LIMIT
The default iteration limit for computing the SVD. |
static int |
OMIT_U
Specifies that the matrix U should not be computed. |
static int |
OMIT_V
Specifies that the matrix V should not be computed. |
Constructor Summary | |
---|---|
SVDecomposition()
Creates an uninitialized SVDecomposition. |
|
SVDecomposition(int flags)
Creates an uninitialized SVDecomposition with the specified computation flags. |
|
SVDecomposition(Matrix M)
Creates an SVDecomposition and initializes it to the SVD for the matrix M. |
|
SVDecomposition(Matrix M,
int flags)
Creates an SVDecomposition, sets the computation flags, and initializes it to the SVD for the matrix M. |
Method Summary | |
---|---|
double |
condition()
Computes the condition number of the original matrix M associated with this SVD. |
double |
determinant()
Computes the determinant of the original matrix M associated with this SVD. |
void |
factor(Matrix M)
Peforms an SVD on the Matrix M. |
void |
get(DenseMatrix U,
Vector svec,
DenseMatrix V)
Gets the matrices associated with the SVD. |
VectorNd |
getEigenValues(DenseMatrix U)
Gets the eigen decomposition for the currently factore (symmetric) matrix M: |
VectorNd |
getEigenValues(DenseMatrix M,
DenseMatrix U)
Factors a matrix M and returns its eigen decomposition: |
int |
getFlags()
Gets the flags associated with SVD computation. |
int |
getIterationLimit()
Gets the iteration limit for SVD computations. |
boolean |
inverse(MatrixNd R)
Computes the inverse of the original matrix M associated this SVD, and places the result in R. |
double |
norm()
Computes the 2-norm of the original matrix M associated with this SVD. |
boolean |
pseudoInverse(MatrixNd R)
Computes the psuedo inverse of the original matrix M associated this SVD, and places the result in R. |
void |
setFlags(int flags)
Sets the flags associated with SVD computation. |
void |
setIterationLimit(int lim)
Sets the iteration limit for SVD computations. |
boolean |
solve(MatrixNd X,
MatrixNd B)
Solves the linear equation M X = B where M is the original matrix associated with this SVD, and X and B are matrices. |
boolean |
solve(VectorNd x,
VectorNd b)
Solves the linear equation M x = b where M is the original matrix associated with this SVD, and x and b are vectors. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int OMIT_U
public static final int OMIT_V
public static final int DEFAULT_ITERATION_LIMIT
Constructor Detail |
---|
public SVDecomposition(Matrix M)
M
- matrix to perform the SVD onpublic SVDecomposition(Matrix M, int flags)
M
- matrix to perform the SVD onflags
- flags associated with SVD computationsetFlags(int)
public SVDecomposition(int flags)
flags
- flags associated with SVD computationsetFlags(int)
public SVDecomposition()
Method Detail |
---|
public void setFlags(int flags)
OMIT_V
and OMIT_U
.
flags
- an or-ed combination of flags.getFlags()
public int getFlags()
setFlags(int)
public int getIterationLimit()
setIterationLimit(int)
public void setIterationLimit(int lim)
lim
- iteration limitgetIterationLimit()
public void factor(Matrix M)
M
- matrix to perform the SVD onpublic void get(DenseMatrix U, Vector svec, DenseMatrix V)
U
- left-hand orthogonal matrixsvec
- vector giving the diagonal elements of SV
- right-hand orthogonal matrix (note that this is V, and not it's transpose
V').
ImproperStateException
- if this SVDecomposition is uninitialized
ImproperSizeException
- if U, svec, or V are not of the proper dimension and cannot be resized.public VectorNd getEigenValues(DenseMatrix M, DenseMatrix U)
M = U E U^Twhere U is orthogonal and E is a diagonal matrix of eigenvalues. It is assumed that M is symmetric. If M is not symmetric, then a symmetric matrix is formed from
1/2 (M + M')
M
- matrix to be factoredU
- left-hand orthogonal matrix (optional, may be null)
java.lang.IllegalArgumentException
- if M is not square
ImproperSizeException
- if U is not of the proper dimension and cannot be resized.public VectorNd getEigenValues(DenseMatrix U)
M = U E U^Twhere U is orthogonal and E is a diagonal matrix of eigenvalues. It is assumed that
factor(M)
was called previously, and
that M is symmetric.
U
- left-hand orthogonal matrix (optional, may be null)
ImproperStateException
- if this SVDecomposition does not contain a factored matrix, or if
that matrix is not square
ImproperSizeException
- if U is not of the proper dimension and cannot be resized.public double condition()
ImproperStateException
- if this SVDecomposition is uninitializedpublic double norm()
ImproperStateException
- if this SVDecomposition is uninitializedpublic double determinant()
ImproperStateException
- if this SVDecomposition is uninitializedpublic boolean solve(VectorNd x, VectorNd b)
x
- unknown vector to solve forb
- constant vector
ImproperStateException
- if this decomposition is uninitialized
ImproperSizeException
- if b does not have a size compatible with M, or if x does not have a size
compatible with M and cannot be resized.public boolean solve(MatrixNd X, MatrixNd B)
X
- unknown matrix to solve forB
- constant matrix
ImproperStateException
- if this decomposition is uninitialized
ImproperSizeException
- if B has a different number of rows than M, or if X has a different number
of rows than M or a different number of columns than B and cannot be
resized.public boolean inverse(MatrixNd R)
R
- matrix in which the inverse is stored
ImproperStateException
- if this decomposition is uninitialized
ImproperSizeException
- if M is not square, or if R does not have the same size as M and cannot be
resized.public boolean pseudoInverse(MatrixNd R)
R
- matrix in which the inverse is stored
ImproperStateException
- if this decomposition is uninitialized
ImproperSizeException
- if M is not square, or if R does not have the same size as M and cannot be
resized.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |