Fn_svd

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)

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

00031   {
00032   arma_extra_debug_sigprint();
00033 
00034   typedef typename T1::elem_type eT;
00035   
00036   // unwrap_check not used as T1::elem_type and T1::pod_type may not be the same.
00037   // furthermore, it doesn't matter if A is an alias of S, as auxlib::svd() makes a copy of A
00038   
00039   const unwrap<T1> tmp(X.get_ref());
00040   const Mat<eT>& A = tmp.M;
00041   
00042   const bool status = auxlib::svd(S, A);
00043     
00044   if(status == false)
00045     {
00046     arma_print("svd(): singular value decomposition failed");
00047     }
00048   
00049   return status;
00050   }

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

00062   {
00063   arma_extra_debug_sigprint();
00064   
00065   Col<typename T1::pod_type> out;
00066   
00067   const bool status = svd(out, X);
00068   
00069   if(status == false)
00070     {
00071     out.set_size(0);
00072     }
00073   
00074   return out;
00075   }

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

00090   {
00091   arma_extra_debug_sigprint();
00092   
00093   typedef typename T1::elem_type eT;
00094   
00095   arma_debug_check( ( ((void*)(&U) == (void*)(&S)) || (&U == &V) || ((void*)(&S) == (void*)(&V)) ), "svd(): two or more output objects are the same object" );
00096   
00097   const unwrap<T1>   tmp(X.get_ref());
00098   const Mat<eT>& A = tmp.M;
00099   
00100   // auxlib::svd() makes an internal copy of A
00101   const bool status = auxlib::svd(U, S, V, A);
00102   
00103   if(status == false)
00104     {
00105     arma_print("svd(): singular value decomposition failed");
00106     }
00107   
00108   return status;
00109   }