CLA3P v0.3.1
Compact Linear Algebra Parallel Portable Package
Loading...
Searching...
No Matches
cla3p::DefaultSVD< T_Matrix > Class Template Reference

Singular Value Decomposition (SVD) implementation for dense matrices. More...

Public Member Functions

 DefaultSVD ()
 Constructs an uninitialized SVD decomposition object.
 DefaultSVD (int_t m, int_t n, svdPolicy_t leftPolicy=svdPolicy_t::Economy, svdPolicy_t rightPolicy=svdPolicy_t::Economy)
 Constructs an SVD object with pre-allocated buffers.
 ~DefaultSVD ()
 Destroys the SVD decomposition object.
void clear ()
 Clears all decomposition results and resets the object.
void reserve (int_t m, int_t n)
 Pre-allocates buffers for decomposition.
svdPolicy_t getLeftPolicy () const
 Retrieves the left singular vector computation policy.
svdPolicy_t getRightPolicy () const
 Retrieves the right singular vector computation policy.
void setLeftPolicy (svdPolicy_t leftPolicy)
 Configures the left singular vector computation policy.
void setRightPolicy (svdPolicy_t rightPolicy)
 Configures the right singular vector computation policy.
void decompose (const T_Matrix &mat)
 Performs Singular Value Decomposition on the input matrix.
const T_RVector & singularValues () const
 Retrieves the computed singular values.
const T_Matrix & leftSingularVectors () const
 Retrieves the left singular vectors matrix.
const T_Matrix & rightSingularVectors () const
 Retrieves the right singular vectors matrix.

Detailed Description

template<typename T_Matrix>
class cla3p::DefaultSVD< T_Matrix >

Singular Value Decomposition (SVD) implementation for dense matrices.

Template Parameters
T_MatrixThe dense matrix type to decompose.

This class provides a complete Singular Value Decomposition interface, decomposing a matrix \( A \) into \( A = U \cdot \Sigma \cdot V^H \), where \( U \) and \( V \) are unitary matrices and \( \Sigma \) is diagonal.

Examples
ex08b_sv_decomposition.cpp.

Constructor & Destructor Documentation

◆ DefaultSVD() [1/2]

template<typename T_Matrix>
cla3p::DefaultSVD< T_Matrix >::DefaultSVD ( )

Constructs an uninitialized SVD decomposition object.

Initializes an empty SVD object with no allocated memory for decomposition results.

◆ DefaultSVD() [2/2]

template<typename T_Matrix>
cla3p::DefaultSVD< T_Matrix >::DefaultSVD ( int_t m,
int_t n,
svdPolicy_t leftPolicy = svdPolicy_t::Economy,
svdPolicy_t rightPolicy = svdPolicy_t::Economy )

Constructs an SVD object with pre-allocated buffers.

Initializes the SVD decomposition object and allocates internal buffers to accommodate matrices up to the specified dimensions.

Parameters
[in]mThe maximum number of matrix rows.
[in]nThe maximum number of matrix columns.
[in]leftPolicyThe singular vector computation policy for \( U \).
[in]rightPolicyThe singular vector computation policy for \( V \).

◆ ~DefaultSVD()

template<typename T_Matrix>
cla3p::DefaultSVD< T_Matrix >::~DefaultSVD ( )

Destroys the SVD decomposition object.

Releases all allocated memory and clears internal data structures.

Member Function Documentation

◆ clear()

template<typename T_Matrix>
void cla3p::DefaultSVD< T_Matrix >::clear ( )

Clears all decomposition results and resets the object.

Deallocates decomposition results and returns the object to its default state.

◆ reserve()

template<typename T_Matrix>
void cla3p::DefaultSVD< T_Matrix >::reserve ( int_t m,
int_t n )

Pre-allocates buffers for decomposition.

Allocates internal buffers to accommodate matrices with up to m rows and n columns. This avoids memory reallocation during subsequent decompositions.

Parameters
[in]mThe maximum number of matrix rows to support.
[in]nThe maximum number of matrix columns to support.

◆ getLeftPolicy()

template<typename T_Matrix>
svdPolicy_t cla3p::DefaultSVD< T_Matrix >::getLeftPolicy ( ) const

Retrieves the left singular vector computation policy.

Returns the policy that determines whether the left singular vectors ( \( U \) matrix) will be computed in full, limited to \( \min(m,n) \) columns, or not at all.

Returns
The current left singular vector computation policy.

◆ getRightPolicy()

template<typename T_Matrix>
svdPolicy_t cla3p::DefaultSVD< T_Matrix >::getRightPolicy ( ) const

Retrieves the right singular vector computation policy.

Returns the policy that determines whether the right singular vectors ( \( V^H \) matrix) will be computed in full, limited to \( \min(m,n) \) rows, or not at all.

Returns
The current right singular vector computation policy.

◆ setLeftPolicy()

template<typename T_Matrix>
void cla3p::DefaultSVD< T_Matrix >::setLeftPolicy ( svdPolicy_t leftPolicy)

Configures the left singular vector computation policy.

Specifies whether the left singular vectors ( \( U \) matrix) should be computed in full, limited to \( \min(m,n) \) columns, or not computed at all.

Parameters
[in]leftPolicyThe left singular vector computation policy.

◆ setRightPolicy()

template<typename T_Matrix>
void cla3p::DefaultSVD< T_Matrix >::setRightPolicy ( svdPolicy_t rightPolicy)

Configures the right singular vector computation policy.

Specifies whether the right singular vectors ( \( V^H \) matrix) should be computed in full, limited to \( \min(m,n) \) rows, or not computed at all.

Parameters
[in]rightPolicyThe right singular vector computation policy.

◆ decompose()

template<typename T_Matrix>
void cla3p::DefaultSVD< T_Matrix >::decompose ( const T_Matrix & mat)

Performs Singular Value Decomposition on the input matrix.

Computes the decomposition \( A = U \cdot \Sigma \cdot V^H \) of the input matrix. The computation respects the singular vector policies set via setLeftPolicy() and setRightPolicy().

Parameters
[in]matThe matrix to decompose.
Examples
ex08b_sv_decomposition.cpp.

◆ singularValues()

template<typename T_Matrix>
const T_RVector & cla3p::DefaultSVD< T_Matrix >::singularValues ( ) const

Retrieves the computed singular values.

Returns the diagonal elements of \( \Sigma \) in descending order.

Returns
A constant reference to a vector of \( \min(m,n) \) singular values.
Examples
ex08b_sv_decomposition.cpp.

◆ leftSingularVectors()

template<typename T_Matrix>
const T_Matrix & cla3p::DefaultSVD< T_Matrix >::leftSingularVectors ( ) const

Retrieves the left singular vectors matrix.

Returns the matrix \( U \) of size \( m \times k \), where:

  • \( k = m \) if left policy is Full
  • \( k = \min(m,n) \) if left policy is Economy
  • The matrix is empty if left policy is NoCalculation
    Returns
    A constant reference to the left singular vectors matrix.
Examples
ex08b_sv_decomposition.cpp.

◆ rightSingularVectors()

template<typename T_Matrix>
const T_Matrix & cla3p::DefaultSVD< T_Matrix >::rightSingularVectors ( ) const

Retrieves the right singular vectors matrix.

Returns the matrix \( V^H \) of size \( k \times n \), where:

  • \( k = n \) if right policy is Full
  • \( k = \min(m,n) \) if right policy is Economy
  • The matrix is empty if right policy is NoCalculation
    Returns
    A constant reference to the right singular vectors matrix.
Examples
ex08b_sv_decomposition.cpp.