synaps/linalg/MATRIXPOL.h

00001 #ifndef SYNAPS_LINALG_MATRIXPOL_H
00002 #define SYNAPS_LINALG_MATRIXPOL_H
00003 
00004 #include <synaps/init.h>
00005 
00006 __BEGIN_NAMESPACE_SYNAPS
00007 
00008 
00009 namespace MATRIXPOL
00010 {
00011   template<class MAT> int  degree(const MAT & P);
00012   template<class MAT, class MatPol> MAT coeffdom(const MatPol & P);
00013 }
00014 
00015 template<class MAT> 
00016 int MATRIXPOL::degree(const MAT & M)
00017 {
00018   typedef typename MAT::size_type size_type;
00019   
00020   int d=-1;
00021   for(size_type i=0; i<M.nbrow(); i++)
00022     for(size_type j=0; j<M.nbrow(); j++)
00023       d= max(d,Degree(M(i,j)));
00024   return d;
00025 }
00026 
00027 template<class MAT, class MatPol>
00028 MAT MATRIXPOL::coeffdom(const MatPol & P) {
00029   MAT N(n,n);int d;
00030   for(int j=0; j<n;j++)
00031     {d=V[j];
00032       for(int i=0; i<n;i++)
00033       if (P(i,j).degree()==d)  N(i,j)=P(i,j)[d];
00034     }
00035   return N;
00036 }
00037 
00038 __END_NAMESPACE_SYNAPS
00039 
00040 #endif // SYNAPS_LINALG_MATRIXPOL_H
00041 

SYNAPS DOCUMENTATION
logo