KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Public Attributes | List of all members
kjb::Svd Struct Reference

a tuple that computes a singular value decomposition of a matrix More...

#include <n_svd.h>

Public Member Functions

void compute_svd (const kjb_c::Matrix *pa)
 wrap call to C library. More...
 
void compute_svd (const Matrix &mat_a)
 overload of compute_svd( kjb_c::Matrix* ) for a wrapped Matrix. More...
 
 Svd (const Matrix &mat_a)
 ctor for tuple calls the library function on a wrapped Matrix More...
 
 Svd (const kjb_c::Matrix *pa)
 ctor for tuple calls the library function on a C-style Matrix More...
 
void swap (Svd &other)
 swap the representations of two SVD tuples More...
 
const Matrixu () const
 const getter for SVD left factor More...
 
const Vectord () const
 const getter for vector of singular values More...
 
const Matrixvt () const
 const getter for SVD right factor More...
 
Matrix reconstruction () const
 this tries to reconstruct the original matrix A from its pieces More...
 

Public Attributes

Vector vec_d
 vector of singular values More...
 
Matrix mat_u
 left factor in SVD product More...
 
Matrix mat_vt
 eigenvectors (right factor in SVD product) More...
 
int rank
 estimated rank of the input matrix More...
 

Detailed Description

a tuple that computes a singular value decomposition of a matrix

See Also
kjb_c::do_svd

This class is just a convenience tuple of two matrices, a vector, and an int that gathers the results of a singular value decomposition (SVD) of some matrix. For details about the SVD particulars, see the man page of function kjb_c::do_svd(), which this class relies upon.

The standard way to use this class is to construct it on a matrix that you wish to decompose. The ctor will launch the analysis, and then the object will contain the results. If you use it this way, you do NOT need to call the "compute_svd()" method.

The reconstruction() method will ideally return you the original matrix from which the SVD was generated, modulo numerical noise. In other words, Your_input_matrix == mat_u * create_diagonal_matrix( vec_d ) * mat_vt at least approximately. Again, see the man page for kjb_c::do_svd() for more details.

Constructor & Destructor Documentation

kjb::Svd::Svd ( const Matrix mat_a)

ctor for tuple calls the library function on a wrapped Matrix

kjb::Svd::Svd ( const kjb_c::Matrix *  pa)

ctor for tuple calls the library function on a C-style Matrix

Member Function Documentation

void kjb::Svd::compute_svd ( const kjb_c::Matrix *  pa)

wrap call to C library.

Most of the time you do not need to call this method, because the constructor calls it automatically.

You only need to call this method if you want to recycle an Svd object. That means you already have one of these objects, but you do not need it anymore, and you want to reuse its current memory allocation to store the SVD of a new matrix. Then this method will save you a few Matrix and Vector destruction/creation cycles. (These sort of time-savings are small, but inside a critical loop it could be worth it.)

void kjb::Svd::compute_svd ( const Matrix mat_a)

overload of compute_svd( kjb_c::Matrix* ) for a wrapped Matrix.

const Vector & kjb::Svd::d ( ) const

const getter for vector of singular values

Matrix kjb::Svd::reconstruction ( ) const

this tries to reconstruct the original matrix A from its pieces

void kjb::Svd::swap ( Svd other)

swap the representations of two SVD tuples

const Matrix & kjb::Svd::u ( ) const

const getter for SVD left factor

const Matrix & kjb::Svd::vt ( ) const

const getter for SVD right factor

Member Data Documentation

Matrix kjb::Svd::mat_u

left factor in SVD product

Matrix kjb::Svd::mat_vt

eigenvectors (right factor in SVD product)

int kjb::Svd::rank

estimated rank of the input matrix

Vector kjb::Svd::vec_d

vector of singular values


The documentation for this struct was generated from the following files: