00001
00002
00003
00004
00005
00006
00007 #ifndef SYNAPS_MPOL_DEGLEX_H
00008 #define SYNAPS_MPOL_DEGLEX_H
00009
00010 #include <synaps/init.h>
00011
00012 __BEGIN_NAMESPACE_SYNAPS
00013
00020 struct DegLex
00021 {
00022 template <class M> static bool less (const M &, const M &);
00023 template <class M> bool operator() (const M & m1, const M & m2) const
00024 {return less(m1,m2);}
00025 };
00026
00027 template <class M>
00028 bool DegLex::less(const M & m1, const M & m2) {
00029
00030 if (degree(m1) < degree(m2) ) return true;
00031 else if (degree(m1) > degree(m2)) return false;
00032 else {
00033 int n1 = m1.nvars(), n2 =m2.nvars();
00034 if(n1 <0 && n2>0) return false;
00035 if(n1 <0 && n2<0) return false;
00036 if(n2 <0 && n1>0) return true;
00037 int n = std::max(n1,n2);
00038 int i = std::max(n,0);
00039 while(i>=0 && m1[i] == m2[i]) i--;
00040 if(i <0)
00041 return false;
00042 else
00043 return (m1[i]> m2[i]);
00044 }
00045 }
00046
00047
00048
00049
00050 __END_NAMESPACE_SYNAPS
00051
00052 #endif // SYNAPS_MPO_DEGLEX_H
00053