#include <Svd.hh>
Collaboration diagram for RazorBack::Svd_:
Public Methods | |
Svd_ (unsigned int Row=3, unsigned int Col=3) | |
Set up SVD for a Row x Col matrix where Row>=Col. More... | |
const Rmatdbl_& | u () const |
Returns the U matrix. | |
const Vecdbl_& | w () const |
Returns the vector of the singular values. | |
const Rmatdbl_& | v () const |
Returns the V matrix. | |
unsigned int | rno () const |
rno() returns the current number of rows. | |
unsigned int | cno () const |
cno() returns the current number of columns. | |
void | set_size (unsigned int Row=3, unsigned int Col=3) |
set_size(): modifies the sizes of the SVD components to accommodate a Row x Col matrix. More... | |
void | make_decomp (const Rmatdbl_ &A) |
make_decomp(A): the SVD done on the general matrix A (which is preserved). More... | |
unsigned int | rank_cond (double Eps=SVD_EPSILON, double *Cond=NULL) |
rank_cond(): checks the singular values after SVD. More... | |
Vecdbl_ | lin_solve (const Vecdbl_ &B) const |
lin_solve(): back-substitution routine for solving linear equations AX=B. More... | |
void | reset_data () |
reset_data(): zeroes the matrices and the W vector. | |
Private Methods | |
void | svd_core () |
void | utb (const Vecdbl_ &B, Vecdbl_ &Utb) const |
Private Attributes | |
Rmatdbl_ | U |
general Row x Col matrix. | |
Vecdbl_ | W |
Col-long vector. | |
Rmatdbl_ | V |
Col x Col square matrix. | |
unsigned int | R |
unsigned int | Rorig |
unsigned int | C |
row and column nos. | |
Static Private Attributes | |
const Safety_ | Safe |
safe division and hypot() classlet. | |
const double | SVD_EPSILON |
a small value. | |
Friends | |
ostream& | operator<< (ostream &Out, const Svd_ &Svd) |
<<: the overloaded output operator. Prints a neat listing to Out. |
SVD decomposes a rectangular matrix A into the form UWV' where W is diagonal and V is square. U and V are Rmatdbl_ objects, W is stored as a Vector_ object. The class supports a few methods for performing SVD and analysing the results. A general linear equation solver is also provided.
Definition at line 46 of file Svd.hh.
|
Set up SVD for a Row x Col matrix where Row>=Col. If Row<Col, then the rows of U will be padded to make it ColxCol with a warning. If either Row or Col is 0, will be changed to 3 (cf matrix/vector ctors) and a warning printed. The default size is also 3x3. The members will be initialised to 0.0 (all elements). |
|
Returns the U matrix.
|
|
Returns the vector of the singular values.
|
|
Returns the V matrix.
|
|
rno() returns the current number of rows.
|
|
cno() returns the current number of columns.
|
|
set_size(): modifies the sizes of the SVD components to accommodate a Row x Col matrix. If Row < Col, then the rows of U will be padded to give a Col x Col matrix. If Row or Col is 0, then 3 will be used instead and a warning printed. Without arguments, the size is set to 3x3. |
|
make_decomp(A): the SVD done on the general matrix A (which is preserved). The three member objects U, W, V will be set in the calling object. Throws Svdexc_ if there was a convergence problem or a div-by-zero attempt in the core routine. |
|
rank_cond(): checks the singular values after SVD. The condition number in *Cond (ratio of the largest and smallest singular value) is also calculated if Cond!=NULL. The singular values which are smaller than Eps times the largest are set to 0.0. Return value: the rank of the matrix. |
|
lin_solve(): back-substitution routine for solving linear equations AX=B. A should be SV-decomposed into U, W and V' by make_decomp() and the weight vector should be "conditioned" (small entries zeroed) by rank_cond() prior to the call to this routine. The right-hand-side vector B must have a dim equal to the original no. of rows in A otherwise a Dimexc_ exception will be thrown. Return value: the X vector. |
|
reset_data(): zeroes the matrices and the W vector.
|
|
|
|
|
|
<<: the overloaded output operator. Prints a neat listing to Out.
|
|
safe division and hypot() classlet.
|
|
a small value.
|
|
general Row x Col matrix.
|
|
Col-long vector.
|
|
Col x Col square matrix.
|
|
|
|
|
|
row and column nos.
|