Module: Linear Algebra Group: Decomposition classes
Does not inherit
#include <rw/lapack/sv.h> #include <rw/lapack/svddccalc.h> RWSVServer<double, RWSVDDivConqCalc<double> > server;
The singular value decomposition server class, RWSVServer<T>, is used to construct instances of the singular value decomposition class, RWSVDecomp<T>. Using a server rather than the standard singular value decomposition constructor gives you control over what is computed.
The template parameter <SVDCalc> determines the algorithm used by the RWSVDecomp<T> class to compute the singular value decomposition and must implement the following method:
NOTE -- For greater flexibility, the user can implement this method, or the Linear Algebra Module provides two classes to perform this function - RWSVDCalc<T> and RWSVDDivConqCalc<T>. Please see their descriptions in this reference guide for more information.
bool computeSVD(const RWGenMat<T>& A,
RWGenMat<T>& U,
RWGenMat<T>& VT,
RWMathVec<norm_type>& sigma,
norm_type tolerance,
int numLeftVecs = -1
int numRightVecs = -1);
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.
// Read a matrix from standard input and print its singular // values. Use a SV decomposition server to prevent computing // the singular vectors. #include <iostream> #include <rw/math/genmat.h> #include <rw/lapack/sv.h> #include <rw/lapack/svddccalc.h> int main() { RWGenMat<double> A; std::cin >> A; RWSVServer<double, RWSVDDivConqCalc<double> > server; server.computeVectors(0); // compute zero vectors RWSVDecomp<double, RWSVDDivConqCalc<double> > SV = server(A); std::cout << "Singular values are " << SV.SingularValues()
<< std::endl; return 0; }
RWSVServer();
Default constructor. Builds a new server, which computes all singular vectors by default.
void computeAllLeftVectors();
Configures the server to compute all left singular vectors.
void computeAllRightVectors();
Configures the server to compute all right singular vectors.
void computeAllVectors();
Configures the server to compute the first min(m,n) singular vectors, where m x n is the size of the input matrix.
void computeDefaultLeftVectors();
Configures the server to compute the first min(m,n) left singular vectors, where m x n is the size of the input matrix.
void computeDefaultRightVectors();
Configures the server to compute the first min(m,n) right singular vectors, where m x n is the size of the input matrix.
void computeDefaultVectors();
Configures the server to compute all singular vectors.
void computeLeftVectors(unsigned n);
Configures the server to compute the first n left singular vectors.
void computeRightVectors(unsigned n);
Configures the server to compute the first n right singular vectors.
void computeVectors(unsigned n);
Configures the server to compute the first n singular vectors.
void RWSVServer<float>::setTolerance(float tol); void RWSVServer<double>::setTolerance(double tol); void RWSVServer<DComplex>::setTolerance(double tol);
Specifies an accuracy to which the singular values should be computed.
RWSVDecomp<T,SVDCalc> operator()(const RWGenMat<T>&);
Computes a singular value decomposition.
© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.