Fn_svd

Functions

template<typename T1 >
bool svd (Col< typename T1::pod_type > &S, const Base< typename T1::elem_type, T1 > &X)
template<typename T1 >
Col< typename T1::pod_type > svd (const Base< typename T1::elem_type, T1 > &X)
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)

Function Documentation

template<typename T1 >
bool svd ( Col< typename T1::pod_type > &  S,
const Base< typename T1::elem_type, T1 > &  X 
) [inline]

Definition at line 25 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().

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

template<typename T1 >
Col<typename T1::pod_type> svd ( const Base< typename T1::elem_type, T1 > &  X  )  [inline]

Definition at line 52 of file fn_svd.hpp.

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

00053   {
00054   arma_extra_debug_sigprint();
00055   
00056   Col<typename T1::pod_type> out;
00057   
00058   const bool status = svd(out, X);
00059   
00060   if(status == false)
00061     {
00062     out.set_size(0);
00063     }
00064   
00065   return out;
00066   }

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 
) [inline]

Definition at line 74 of file fn_svd.hpp.

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

00080   {
00081   arma_extra_debug_sigprint();
00082   
00083   typedef typename T1::elem_type eT;
00084   
00085   arma_debug_check( ( ((void*)(&U) == (void*)(&S)) || (&U == &V) || ((void*)(&S) == (void*)(&V)) ), "svd(): two or more output objects are the same object" );
00086   
00087   const unwrap<T1>   tmp(X.get_ref());
00088   const Mat<eT>& A = tmp.M;
00089   
00090   // auxlib::svd() makes an internal copy of A
00091   const bool status = auxlib::svd(U, S, V, A);
00092   
00093   if(status == false)
00094     {
00095     arma_print("svd(): singular value decomposition failed");
00096     }
00097   
00098   return status;
00099   }