Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

RazorBack::Svd_ Class Reference

Class Svd_ : a simple class for Singular Value Decomposition. More...

#include <Svd.hh>

Collaboration diagram for RazorBack::Svd_:

Collaboration graph
[legend]
List of all members.

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.


Detailed Description

Class Svd_ : a simple class for Singular Value Decomposition.

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.


Constructor & Destructor Documentation

RazorBack::Svd_::Svd_ ( unsigned int Row = 3,
unsigned int Col = 3 ) [explicit]
 

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).


Member Function Documentation

const Rmatdbl_ & RazorBack::Svd_::u ( ) const [inline]
 

Returns the U matrix.

Definition at line 73 of file Svd.hh.

const Vecdbl_ & RazorBack::Svd_::w ( ) const [inline]
 

Returns the vector of the singular values.

Definition at line 76 of file Svd.hh.

const Rmatdbl_ & RazorBack::Svd_::v ( ) const [inline]
 

Returns the V matrix.

Definition at line 79 of file Svd.hh.

unsigned int RazorBack::Svd_::rno ( ) const [inline]
 

rno() returns the current number of rows.

Definition at line 82 of file Svd.hh.

unsigned int RazorBack::Svd_::cno ( ) const [inline]
 

cno() returns the current number of columns.

Definition at line 85 of file Svd.hh.

void RazorBack::Svd_::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.

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.

void RazorBack::Svd_::make_decomp ( const Rmatdbl_ & A )
 

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.

unsigned int RazorBack::Svd_::rank_cond ( double Eps = SVD_EPSILON,
double * Cond = NULL )
 

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.

Vecdbl_ RazorBack::Svd_::lin_solve ( const Vecdbl_ & B ) const
 

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.

void RazorBack::Svd_::reset_data ( ) [inline]
 

reset_data(): zeroes the matrices and the W vector.

Definition at line 127 of file Svd.hh.

void RazorBack::Svd_::svd_core ( ) [private]
 

void RazorBack::Svd_::utb ( const Vecdbl_ & B,
Vecdbl_ & Utb ) const [private]
 


Friends And Related Function Documentation

ostream & operator<< ( ostream & Out,
const Svd_ & Svd ) [friend]
 

<<: the overloaded output operator. Prints a neat listing to Out.


Member Data Documentation

const Safety_ RazorBack::Svd_::Safe [static, private]
 

safe division and hypot() classlet.

Definition at line 51 of file Svd.hh.

const double RazorBack::Svd_::SVD_EPSILON [static, private]
 

a small value.

Definition at line 52 of file Svd.hh.

Rmatdbl_ RazorBack::Svd_::U [private]
 

general Row x Col matrix.

Definition at line 54 of file Svd.hh.

Vecdbl_ RazorBack::Svd_::W [private]
 

Col-long vector.

Definition at line 55 of file Svd.hh.

Rmatdbl_ RazorBack::Svd_::V [private]
 

Col x Col square matrix.

Definition at line 56 of file Svd.hh.

unsigned int RazorBack::Svd_::R [private]
 

Definition at line 57 of file Svd.hh.

unsigned int RazorBack::Svd_::Rorig [private]
 

Definition at line 57 of file Svd.hh.

unsigned int RazorBack::Svd_::C [private]
 

row and column nos.

Definition at line 57 of file Svd.hh.


The documentation for this class was generated from the following file:
Generated at Wed Aug 21 09:33:27 2002 for The Razorback C++ Library: Linear Algebra by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001