Functions

Fn_svd

//! More...

Functions

template<typename T1 >
bool svd (Col< typename T1::pod_type > &S, const Base< typename T1::elem_type, T1 > &X, const typename arma_blas_type_only< typename T1::elem_type >::result *junk=0)
template<typename T1 >
Col< typename T1::pod_type > svd (const Base< typename T1::elem_type, T1 > &X, const typename arma_blas_type_only< typename T1::elem_type >::result *junk=0)
template<typename T1 >
bool svd (Mat< typename T1::elem_type > &U, Col< typename T1::pod_type > &S, Mat< typename T1::elem_type > &V, const Base< typename T1::elem_type, T1 > &X, const typename arma_blas_type_only< typename T1::elem_type >::result *junk=0)

Detailed Description

//!


Function Documentation

template<typename T1 >
bool svd ( Col< typename T1::pod_type > &  S,
const Base< typename T1::elem_type, T1 > &  X,
const typename arma_blas_type_only< typename T1::elem_type >::result *  junk = 0 
) [inline]

Definition at line 26 of file fn_svd.hpp.

References arma_print(), Base< elem_type, derived >::get_ref(), and auxlib::svd().

Referenced by op_pinv::direct_pinv(), op_princomp::direct_princomp(), op_princomp_cov::direct_princomp_cov(), and svd().

  {
  arma_extra_debug_sigprint();

  typedef typename T1::elem_type eT;
  
  // unwrap_check not used as T1::elem_type and T1::pod_type may not be the same.
  // furthermore, it doesn't matter if A is an alias of S, as auxlib::svd() makes a copy of A
  
  const unwrap<T1> tmp(X.get_ref());
  const Mat<eT>& A = tmp.M;
  
  const bool status = auxlib::svd(S, A);
    
  if(status == false)
    {
    arma_print("svd(): singular value decomposition failed");
    }
  
  return status;
  }

template<typename T1 >
Col<typename T1::pod_type> svd ( const Base< typename T1::elem_type, T1 > &  X,
const typename arma_blas_type_only< typename T1::elem_type >::result *  junk = 0 
) [inline]

Definition at line 58 of file fn_svd.hpp.

References Col< eT >::set_size(), and svd().

  {
  arma_extra_debug_sigprint();
  
  Col<typename T1::pod_type> out;
  
  const bool status = svd(out, X);
  
  if(status == false)
    {
    out.set_size(0);
    }
  
  return out;
  }

template<typename T1 >
bool svd ( Mat< typename T1::elem_type > &  U,
Col< typename T1::pod_type > &  S,
Mat< typename T1::elem_type > &  V,
const Base< typename T1::elem_type, T1 > &  X,
const typename arma_blas_type_only< typename T1::elem_type >::result *  junk = 0 
) [inline]

Definition at line 83 of file fn_svd.hpp.

References arma_print(), Base< elem_type, derived >::get_ref(), and auxlib::svd().

  {
  arma_extra_debug_sigprint();
  
  typedef typename T1::elem_type eT;
  
  arma_debug_check( ( ((void*)(&U) == (void*)(&S)) || (&U == &V) || ((void*)(&S) == (void*)(&V)) ), "svd(): two or more output objects are the same object" );
  
  const unwrap<T1>   tmp(X.get_ref());
  const Mat<eT>& A = tmp.M;
  
  // auxlib::svd() makes an internal copy of A
  const bool status = auxlib::svd(U, S, V, A);
  
  if(status == false)
    {
    arma_print("svd(): singular value decomposition failed");
    }
  
  return status;
  }