Main Page | Class Hierarchy | Class List | File List | Class Members

PLib::SVDMatrix< T > Class Template Reference

A matrix for the SVD decomposition. More...

#include <matrix/matrixMat.h>

List of all members.

Public Member Functions

 SVDMatrix (const Matrix< T > &A)
int decompose (const Matrix< T > &A)
void minMax (T &min_sig, T &max_sig) const
double q_cond_number (void) const
void cut_off (const double min_sig)
void inverseIn (Matrix< T > &inv, double tau=0)
Matrix< T > inverse (double tau=0)
int solve (const Matrix< T > &B, Matrix< T > &X, double tau=0)

Public Attributes

const Matrix< T > & U
const Matrix< T > & V
const Vector< T > & sig

Protected Member Functions

double left_householder (Matrix< T > &A, const int i)
double right_householder (Matrix< T > &A, const int i)
double bidiagonalize (Vector< T > &super_diag, const Matrix< T > &_A)
void rotate (Matrix< T > &U, const int i, const int j, const double cos_ph, const double sin_ph)
void rip_through (Vector< T > &super_diag, const int k, const int l, const double eps)
int get_submatrix_to_work_on (Vector< T > &super_diag, const int k, const double eps)
void diagonalize (Vector< T > &super_diag, const double eps)

Protected Attributes

int M
int N
Matrix< T > U_
Matrix< T > V_
Vector< T > sig_


Detailed Description

template<class T>
class PLib::SVDMatrix< T >

A matrix for the SVD decomposition.

This matrix was adapted from the Numerical Math Class Library developed by Oleg Kiselyov.

This class can only be used with floating point values (float or double).

The following comments are from Oleg Kiselyov.

Singular Value Decomposition of a rectangular matrix A=U Sig V' where matrices U and V are orthogonal and Sig is a diagonal matrix.

The singular value decomposition is performed by constructing an SVD object from an M*N matrix A with M \ge N (that is, at least as many rows as columns). Note, in case M > N, matrix Sig has to be a M*N diagonal matrix. However, it has only N diagonal elements, which we store in a vector sig.

Algorithm: Bidiagonalization with Householder reflections followed by a modification of a QR-algorithm. For more details, see G.E. Forsythe, M.A. Malcolm, C.B. Moler Computer methods for mathematical computations, Prentice-Hall, 1977. However, in the present implementation, matrices U and V are computed right away rather than delayed until after all Householder reflections.

This code is based for the most part on a Algol68 code I (Oleg Kiselyov) wrote ca. 1987.

Look at the source code for more information about the algorithm.

Author:
Oleg Kiselyov

Philippe Lavoie

Date:
22 Oct. 1997


Constructor & Destructor Documentation

template<class T>
PLib::SVDMatrix< T >::SVDMatrix const Matrix< T > &  A  ) 
 

Performs the SVD decomposition of A.

Performs the SVD decomposition of A. It is not recommended to use this routine has errors from the decomposition routine are discarded

Parameters:
A the matrix to decompose
Warning:
The matrix A must have a number equal or higher of rows than columns.
Author:
Philippe Lavoie
Date:
22 October 1997


Member Function Documentation

template<class T>
int PLib::SVDMatrix< T >::decompose const Matrix< T > &  A  ) 
 

Performs the SVD decomposition of A.

Performs the SVD decomposition of A.

Parameters:
A the matrix to decompose
Returns:
1 if the decomposition was succesfull, 0 otherwise.
Warning:
The matrix A must have a number equal or higher of rows than columns.
Author:
Philippe Lavoie
Date:
22 October 1997

template<class T>
Matrix< T > PLib::SVDMatrix< T >::inverse double  tau = 0  ) 
 

Finds the (pseudo-)inverse of a SVD matrix.

Finds the (pseudo-)inverse of a SVD matrix.

Parameters:
tau the minimal singular value accepted
Warning:
The SVD matrix must be valid.
Author:
Philippe Lavoie
Date:
22 October 1997

template<class T>
void PLib::SVDMatrix< T >::inverseIn Matrix< T > &  A,
double  tau = 0
 

Finds the (pseudo-)inverse of a SVD matrix.

Finds the (pseudo-)inverse of a SVD matrix.

Parameters:
A the inverse of the SVD matrix
tau the minimal singular value accepted
Warning:
The SVD matrix must be valid.
Author:
Philippe Lavoie
Date:
22 October 1997

template<class T>
void PLib::SVDMatrix< T >::minMax T &  min_sig,
T &  max_sig
const
 

Finds the minimal and maximal sigma values.

Finds the minimal and maximal sigma values.

Parameters:
min_sig the minimal sigma value
max_sig the maximal sigma value
Warning:
The SVD matrix must be valid.
Author:
Philippe Lavoie
Date:
22 October 1997

template<class T>
double PLib::SVDMatrix< T >::q_cond_number void   )  const
 

Finds the condition number.

Finds the condition number which corresponds to the maximal sigma value divided by its minimal value.

Returns:
The condition number
Warning:
The SVD matrix must be valid.
Author:
Philippe Lavoie
Date:
22 October 1997

template<class T>
int PLib::SVDMatrix< T >::solve const Matrix< T > &  B,
Matrix< T > &  X,
double  tau = 0
 

Solves the linear system A X = B.

Solves the linear system A X = B. Given A and B it finds the value of X. A is the SVD matrix properly initialized and the only other input parameter is B.

Parameters:
B the right hand side of the equation
X the resulting matrix
tau the minimal singular value accepted
Returns:
1 if the routine was able to solve the problem, 0 otherwise.
Warning:
The SVD matrix must be valid and correspond to A.
Author:
Philippe Lavoie
Date:
22 October 1997


Member Data Documentation

template<class T>
int PLib::SVDMatrix< T >::N [protected]
 

Dimensions of the problem (M > N).

template<class T>
Vector<T> PLib::SVDMatrix< T >::sig_ [protected]
 

Vector of N unordered singular values.

template<class T>
Matrix<T> PLib::SVDMatrix< T >::U_ [protected]
 

M * M orthogonal matrix U.

template<class T>
Matrix<T> PLib::SVDMatrix< T >::V_ [protected]
 

N * N orthogonal matrix V.


The documentation for this class was generated from the following files:
Generated on Wed Aug 18 07:07:37 2004 for NURBS++ by doxygen 1.3.7