00001
00002
00003
00004
00005
00006
00007
00008 #ifndef SYNAPS_MPOL_SQVLEX_H
00009 #define SYNAPS_MPOL_SQVLEX_H
00010
00011 #include <synaps/init.h>
00012
00013 __BEGIN_NAMESPACE_SYNAPS
00014
00015
00022 struct SQVlex {
00023 template <class M>
00024 static bool less (const M &, const M &);
00025 template <class M>
00026 bool operator() (const M &, const M &) {return less(m1,m2);}
00027 };
00028
00029
00030 template <class M>
00031 bool SQVlex::less(const M & m1, const M & m2) {
00032
00033 int n1 = m1.nvars(), n2 =m2.nvars();
00034 int n = max(n1,n2);
00035
00036 if(n1 <0 && n2>0) return false;
00037 if(n2 <0 && n1>0) return true;
00038 if(n1 <0 && n2<0) return false;
00039
00040 int d1=0,d2=0, k, c1, c2;
00041 for(int i =0 ; i<= n1; i++) {c1 = max(d1,(k=m1[i]));d1+=k;}
00042 for(int i =0 ; i<= n2; i++) {c2 = max(d2,(k=m2[i]));d2+=k;}
00043
00044 if (c1 < c2) return false;
00045 else if (c1 > c2) return true;
00046 else if (d1 < d2) return false;
00047 else if (d1 > d2) return true;
00048 else {
00049 int i=n;
00050 while( m1[i] == m2[i] && i>=0) i--;
00051 if(i <0)
00052 return false;
00053 else
00054 return (m1[i]> m2[i]);
00055 }
00056 }
00057
00058 __END_NAMESPACE_SYNAPS
00059
00060 #endif // SYNAPS_MPOL_SQVLEX_H
00061