SourcePro® 2023.1 |
SourcePro® API Reference Guide |
Used to construct and work with singular value decompositions. More...
#include <rw/lapack/sv.h>
Public Types | |
typedef rw_numeric_traits< TypeT >::norm_type | norm_type |
Public Member Functions | |
RWSVDecomp () | |
RWSVDecomp (const RWSVDecomp< TypeT, SVDCalc > &A) | |
RWSVDecomp (const RWGenMat< TypeT > &A, norm_type tol=0) | |
unsigned | cols () const |
void | factor (const RWGenMat< TypeT > &A, norm_type tol=0) |
bool | fail () const |
bool | good () const |
const RWMathVec< TypeT > | leftVector (int i) const |
const RWGenMat< TypeT > | leftVectors () const |
unsigned | numLeftVectors () const |
unsigned | numRightVectors () const |
RWSVDecomp< TypeT, SVDCalc > & | operator= (const RWSVDecomp< TypeT, SVDCalc > &x) |
unsigned | rank () const |
const RWMathVec< TypeT > | rightVector (int i) const |
const RWGenMat< TypeT > | rightVectors () const |
unsigned | rows () const |
norm_type | singularValue (int i) const |
const RWMathVec< norm_type > | singularValues () const |
void | truncate (norm_type tol) |
A singular value decomposition is a representation of a matrix A of the form:
\[ A = UEV' \]
where U and V are orthogonal, and E is diagonal. The entries along the diagonal of E are the singular values; the columns of U are the left singular vectors, and the columns of V are the right singular vectors.
The class RWSVDecomp is used to construct and work with singular value decompositions. The singular values are always ordered smallest to largest with this class. You may need more control over the computation of the decomposition than is provided by this class. For example, if you don't need all the singular vectors, you can use the SV decomposition server class, RWSVServer, to do the construction.
The template parameter <SVDCalc>
determines the algorithm used by the RWSVDecomp class to compute the singular value decomposition and must implement the following method:
where norm_type is a typedef for rw_numeric_traits<T>::norm_type.
Parameters:
A - The input matrix for which the singular value decomposition is being computed.
U - The output matrix of left singular victors (the columns of U are the left singular vectors).
VT - The output matrix of right singular victors (the rows of VT are the right singular victors).
sigma - The output vector of singular values in descending order.
tolerance - The input singular values with magnitude less than tolerance will be set to zero.
numLeftVectors - The input number of left vectors to compute. If the number is less than zero, the default number of vectors will be computed (it is up to the developer to determine what the default is).
numRightVectors - The input number of right vectors to compute. If the number is less than zero, the default number of vectors will be computed (it is up to the developer to determine what the default is).
The return value is true
if the decomposition was successfully computed.
typedef rw_numeric_traits<TypeT>::norm_type RWSVDecomp< TypeT, SVDCalc >::norm_type |
Typedef for the usual return type of numerical norm
-like functions. For more information, see rw_numeric_traits<T>::norm_type.
RWSVDecomp< TypeT, SVDCalc >::RWSVDecomp | ( | ) |
Default constructor. Builds a decomposition of size 0 x 0.
RWSVDecomp< TypeT, SVDCalc >::RWSVDecomp | ( | const RWSVDecomp< TypeT, SVDCalc > & | A | ) |
Copy constructor. References the data in the original decomposition for efficiency.
RWSVDecomp< TypeT, SVDCalc >::RWSVDecomp | ( | const RWGenMat< TypeT > & | A, |
norm_type | tol = 0 |
||
) |
Builds a singular value decomposition of A. The parameter tol specifies the accuracy to which the singular values are required. By default, they are computed to within machine precision. To construct a singular value decomposition with non-default options, you can use the singular value decomposition server classes RWSVServer.
|
inline |
Returns the number of columns in the matrix that the decomposition represents.
void RWSVDecomp< TypeT, SVDCalc >::factor | ( | const RWGenMat< TypeT > & | A, |
norm_type | tol = 0 |
||
) |
Builds a singular value decomposition of A. The parameter tol specifies the accuracy to which the singular values are required. By default, they are computed to within machine precision. To construct a singular value decomposition with non-default options, you can use the singular value decomposition server class RWSVServer.
|
inline |
Returns an indication of whether all singular values are successfully computed.
|
inline |
Returns an indication of whether all singular values are successfully computed.
const RWMathVec<TypeT> RWSVDecomp< TypeT, SVDCalc >::leftVector | ( | int | i | ) | const |
Returns the i th left singular vector. Throws an exception if the i th vector is not computed.
|
inline |
Returns a matrix whose columns are the left singular vectors.
|
inline |
Returns the number of left singular vectors computed.
|
inline |
Returns the number of right singular vectors computed.
RWSVDecomp<TypeT, SVDCalc>& RWSVDecomp< TypeT, SVDCalc >::operator= | ( | const RWSVDecomp< TypeT, SVDCalc > & | x | ) |
Assigns the passed value to this decomposition. The current contents of the decomposition are lost.
|
inline |
Returns the rank of the matrix. The rank is indicated by the number of nonzero singular values.
const RWMathVec<TypeT> RWSVDecomp< TypeT, SVDCalc >::rightVector | ( | int | i | ) | const |
Returns the i th right singular vector. Throws an exception if the i th vector is not computed.
|
inline |
Returns a matrix whose columns are the right singular vectors.
|
inline |
Returns the number of rows in the matrix that the decomposition represents.
norm_type RWSVDecomp< TypeT, SVDCalc >::singularValue | ( | int | i | ) | const |
Returns the i th singular value.
|
inline |
Returns the vector of singular values.
void RWSVDecomp< TypeT, SVDCalc >::truncate | ( | norm_type | tol | ) |
Truncates all singular values with magnitude less than tol by setting them to 0. If tol is a measure of the expected error in entries of the matrix, this truncation provides a more meaningful decomposition. The rank of the decomposition is a measure of the numerical rank of the matrix.
Copyright © 2023 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |