synaps/linalg/Rank.h

Go to the documentation of this file.
00001 /*********************************************************************
00002 *      This file is part of the source code of SYNAPS kernel.        *
00003 *   Author(s): B. Mourrain, GALAAD, INRIA                            *
00004 **********************************************************************
00005 $Id: Rank.h,v 1.1 2005/07/11 08:33:34 mourrain Exp $
00006 **********************************************************************/
00008 #ifndef SYNAPS_LINALG_RANK_H
00009 #define SYNAPS_LINALG_RANK_H
00010 
00011 #include <synaps/init.h>
00012 #include <synaps/linalg/MATRIX.m>
00013 
00014 __BEGIN_NAMESPACE_SYNAPS
00015 
00016 
00017 //----------------------------------------------------------------------
00018 namespace lapack {
00019   template<class R> struct rep;
00020 }
00021 //--------------------------------------------------------------------
00025 template<class R> inline
00026 typename R::size_type Rank(const R & m) 
00027 {
00028   using namespace MATRIX;
00029   return rank(m.rep());
00030 }
00031 //--------------------------------------------------------------------
00035 template<class R,class MTH> inline
00036 typename R::size_type Rank(const R & m, const MTH& mth) 
00037 {
00038   using MATRIX::rank;
00039   return rank(mth,m.rep());
00040 }
00041 //----------------------------------------------------------------------
00047 template<class R,class V> 
00048 typename R::size_type Rank(const R & M, 
00049                            V & I, V & J)
00050 {
00051   lapack::rep<typename R::value_type> A(M.nbrow(),M.nbcol());
00052   assign(A,M);
00053   return rank(A,I.begin(), J.begin());
00054 }
00055 //----------------------------------------------------------------------
00062 template<class R,class I> 
00063 R Extract(R & M, const I & ipvt, const I & jpvt, 
00064                 const typename R::size_type & rank)
00065 {
00066    R SM(rank,rank);
00067    for (typename R::size_type i=0; i<rank; i++)
00068      for (typename R::size_type j = 0; j < rank; j++) 
00069        SM(i,j)=M(ipvt[i],jpvt[j]);
00070    return (SM);
00071 }
00072 //--------------------------------------------------------------------
00073 __END_NAMESPACE_SYNAPS
00074 //--------------------------------------------------------------------
00075 #endif // SYNAPS_LINALG_RANK_H
00076 
00077 

SYNAPS DOCUMENTATION
logo