fn_svd.hpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 template<typename T1>
00023 inline
00024 bool
00025 svd(Col<typename T1::pod_type>& S, const Base<typename T1::elem_type,T1>& X)
00026 {
00027 arma_extra_debug_sigprint();
00028
00029 typedef typename T1::elem_type eT;
00030
00031
00032
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 }
00046
00047
00048
00049 template<typename T1>
00050 inline
00051 Col<typename T1::pod_type>
00052 svd(const Base<typename T1::elem_type,T1>& X)
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 }
00067
00068
00069
00070 template<typename T1>
00071 inline
00072 bool
00073 svd
00074 (
00075 Mat<typename T1::elem_type>& U,
00076 Col<typename T1::pod_type>& S,
00077 Mat<typename T1::elem_type>& V,
00078 const Base<typename T1::elem_type,T1>& X
00079 )
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
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 }
00100
00101
00102
00103