Esempio n. 1
0
File: svd.hpp Progetto: atyuwen/nt2
//==========================================================================
    /// INTERNAL ONLY - [U,S,V] = SVD(X,0)
    BOOST_FORCEINLINE
    void eval ( A0& a0, A1& a1
              , nt2::container::table<type_t>& s    , nt2::container::table<ctype_t>& /*u*/
              , nt2::container::table<ctype_t>& vt
              , int const&
              ) const
    {
      nt2::container::table<ctype_t> work = boost::proto::child_c<0>(a0);

      char jobu = 'A';
      char jobvt = 'A';

      nt2_la_int  m  = nt2::height(work);
      nt2_la_int  n  = nt2::width(work);

      s.resize(nt2::of_size(std::min(m,n), 1));
      vt.resize(nt2::of_size(n,n));


      if(m>n)
      {
        jobu = 'S';
        boost::proto::child_c<0>(a1).resize(nt2::of_size(m,n));
      }
      else boost::proto::child_c<0>(a1).resize(nt2::of_size(m,m)) ;

      nt2_la_int info = nt2::gesvd( boost::proto::value(work), boost::proto::value(s)
                       , boost::proto::value(boost::proto::child_c<0>(a1))
                       , boost::proto::value(vt),jobu,jobvt );
      boost::dispatch::ignore_unused(info);

      boost::proto::child_c<2>(a1) = nt2::trans(vt);
      boost::proto::child_c<1>(a1) = nt2::from_diag(s);
  }
 static void resize ( nt2::container::table<T,S> &v1
                    , const nt2::container::table<T,S> &v2
                    )
 {
   v1.resize( v2.extent() );
 }
 static bool same_size ( const nt2::container::table<T,S> &v1
                       , const nt2::container::table<T,S> &v2
                       )
 {
   return v1.extent() == v2.extent();
 }