|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmaspack.matrix.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_MAX_ITERATIONS
The default maximum iteration count 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(int flags)
Creates an uninitialized SVDecomposition with the specified computation flags. |
|
SVDecomposition(MatrixObject M)
Creates an SVDecomposition and initializes it to the SVD for the matrix M. |
|
SVDecomposition(MatrixObject 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 |
get(MatrixObject U,
VectorObject svec,
MatrixObject V)
Gets the matrices associated with the SVD. |
int |
getFlags()
Gets the flags associated with SVD computation. |
int |
getMaxIterations()
Gets the maximum number of iterations allowed 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. |
void |
set(MatrixObject M)
Peforms an SVD on the MatrixObject M. |
void |
setFlags(int flags)
Sets the flags associated with SVD computation. |
void |
setMaxIterations(int max)
Sets the maximum number of iterations allowed 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_MAX_ITERATIONS
Constructor Detail |
public SVDecomposition(MatrixObject M)
M
- matrix to perform the SVD onpublic SVDecomposition(MatrixObject 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)
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 getMaxIterations()
setMaxIterations(int)
public void setMaxIterations(int max)
max
- maximum number of iterationsgetMaxIterations()
public void set(MatrixObject M)
M
- matrix to perform the SVD onpublic void get(MatrixObject U, VectorObject svec, MatrixObject 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 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.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |