fn_svd.hpp
Go to the documentation of this file.
00001 // Copyright (C) 2009-2011 NICTA (www.nicta.com.au)
00002 // Copyright (C) 2009-2011 Conrad Sanderson
00003 // 
00004 // This file is part of the Armadillo C++ library.
00005 // It is provided without any warranty of fitness
00006 // for any purpose. You can redistribute this file
00007 // and/or modify it under the terms of the GNU
00008 // Lesser General Public License (LGPL) as published
00009 // by the Free Software Foundation, either version 3
00010 // of the License or (at your option) any later version.
00011 // (see http://www.opensource.org/licenses for more info)
00012 
00013 
00016 
00017 
00018 
00019 template<typename T1>
00020 inline
00021 bool
00022 svd
00023   (
00024          Col<typename T1::pod_type>&     S,
00025   const Base<typename T1::elem_type,T1>& X,
00026   const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0
00027   )
00028   {
00029   arma_extra_debug_sigprint();
00030   arma_ignore(junk);
00031   
00032   // it doesn't matter if X is an alias of S, as auxlib::svd() makes a copy of X
00033   
00034   const bool status = auxlib::svd(S, X);
00035   
00036   if(status == false)
00037     {
00038     S.reset();
00039     arma_bad("svd(): failed to converge", false);
00040     }
00041   
00042   return status;
00043   }
00044 
00045 
00046 
00047 template<typename T1>
00048 inline
00049 Col<typename T1::pod_type>
00050 svd
00051   (
00052   const Base<typename T1::elem_type,T1>& X,
00053   const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0
00054   )
00055   {
00056   arma_extra_debug_sigprint();
00057   arma_ignore(junk);
00058   
00059   Col<typename T1::pod_type> out;
00060   
00061   const bool status = auxlib::svd(out, X);
00062   
00063   if(status == false)
00064     {
00065     out.reset();
00066     arma_bad("svd(): failed to converge");
00067     }
00068   
00069   return out;
00070   }
00071 
00072 
00073 
00074 template<typename T1>
00075 inline
00076 bool
00077 svd
00078   (
00079          Mat<typename T1::elem_type>&    U,
00080          Col<typename T1::pod_type >&    S,
00081          Mat<typename T1::elem_type>&    V,
00082   const Base<typename T1::elem_type,T1>& X,
00083   const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0
00084   )
00085   {
00086   arma_extra_debug_sigprint();
00087   arma_ignore(junk);
00088   
00089   typedef typename T1::elem_type eT;
00090   
00091   arma_debug_check
00092     (
00093     ( ((void*)(&U) == (void*)(&S)) || (&U == &V) || ((void*)(&S) == (void*)(&V)) ),
00094     "svd(): two or more output objects are the same object"
00095     );
00096   
00097   // auxlib::svd() makes an internal copy of X
00098   const bool status = auxlib::svd(U, S, V, X);
00099   
00100   if(status == false)
00101     {
00102     U.reset();
00103     S.reset();
00104     V.reset();
00105     arma_bad("svd(): failed to converge", false);
00106     }
00107   
00108   return status;
00109   }
00110 
00111 
00112 
00113 template<typename T1>
00114 inline
00115 bool
00116 svd_econ
00117   (
00118          Mat<typename T1::elem_type>&    U,
00119          Col<typename T1::pod_type >&    S,
00120          Mat<typename T1::elem_type>&    V,
00121   const Base<typename T1::elem_type,T1>& X,
00122   const char                             mode = 'b',
00123   const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0
00124   )
00125   {
00126   arma_extra_debug_sigprint();
00127   arma_ignore(junk);
00128   
00129   typedef typename T1::elem_type eT;
00130   
00131   arma_debug_check
00132     (
00133     ( ((void*)(&U) == (void*)(&S)) || (&U == &V) || ((void*)(&S) == (void*)(&V)) ),
00134     "svd_econ(): two or more output objects are the same object"
00135     );
00136   
00137   arma_debug_check
00138     (
00139     ( (mode != 'l') && (mode != 'r') && (mode != 'b') ),
00140     "svd_econ(): parameter 'mode' is incorrect"
00141     );
00142   
00143   
00144   // auxlib::svd_econ() makes an internal copy of X
00145   const bool status = auxlib::svd_econ(U, S, V, X, mode);
00146   
00147   if(status == false)
00148     {
00149     U.reset();
00150     S.reset();
00151     V.reset();
00152     arma_bad("svd_econ(): failed to converge", false);
00153     }
00154   
00155   return status;
00156   }
00157 
00158 
00159 
00160 template<typename T1>
00161 arma_deprecated
00162 inline
00163 bool
00164 svd_thin
00165   (
00166          Mat<typename T1::elem_type>&    U,
00167          Col<typename T1::pod_type >&    S,
00168          Mat<typename T1::elem_type>&    V,
00169   const Base<typename T1::elem_type,T1>& X,
00170   const char                             mode = 'b',
00171   const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0
00172   )
00173   {
00174   arma_ignore(junk);
00175   
00176   return svd_econ(U,S,V,X,mode);
00177   }
00178 
00179 
00180 


armadillo_matrix
Author(s): Conrad Sanderson - NICTA (www.nicta.com.au), (Wrapper by Sjoerd van den Dries)
autogenerated on Tue Jan 7 2014 11:42:04