00001 // This is core/vnl/algo/vnl_svd_economy.h 00002 #ifndef vnl_svd_economy_h_ 00003 #define vnl_svd_economy_h_ 00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE 00005 #pragma interface 00006 #endif 00007 //: 00008 // \file 00009 // \brief SVD wrapper that doesn't compute the left singular vectors, U. 00010 // \author David Capel (d.capel@2d3.com) 00011 // \date 04 Mar 03 00012 // 00013 // The cost of SVD of an m*n matrix increases with O(m^2) if computation 00014 // of U is required, but only O(m) if not. 00015 00016 #include <vnl/vnl_numeric_traits.h> 00017 #include <vnl/vnl_vector.h> 00018 #include <vnl/vnl_matrix.h> 00019 00020 template <class real_t> 00021 class vnl_svd_economy 00022 { 00023 public: 00024 //: The singular values of a matrix of complex<T> are of type T, not complex<T> 00025 typedef typename vnl_numeric_traits<real_t>::abs_t singval_t; 00026 00027 vnl_svd_economy(vnl_matrix<real_t> const& M); 00028 00029 //: Return right singular vectors. 00030 vnl_matrix<real_t> const& V() const { return V_; } 00031 vnl_matrix<real_t> & V() { return V_; } 00032 00033 //: Return singular values in decreasing order. 00034 vnl_vector<singval_t> const& lambdas() const { return sv_; } 00035 vnl_vector<singval_t> & lambdas() { return sv_; } 00036 00037 //: Return the rightmost column of V. 00038 vnl_vector<real_t> nullvector(); 00039 00040 protected: 00041 long m_, n_; 00042 vnl_matrix<real_t> V_; 00043 vnl_vector<singval_t> sv_; 00044 00045 private: 00046 vnl_svd_economy( vnl_svd_economy<real_t> const&) { } 00047 vnl_svd_economy<real_t>& operator=(vnl_svd_economy<real_t> const&) { return *this; } 00048 }; 00049 00050 #endif