Borderbasix

Rlex.hpp
Go to the documentation of this file.
1 
2 #ifndef _Rlex_H_
3 #define _Rlex_H_
4 
13 template <class M> struct Rlex
14 {
15  static bool less (const M &, const M &);
16  bool operator() (const M &, const M &);
17 };
18 
19 template <class M>
20 bool Rlex<M>::less (const M & m1, const M & m2) {
21  int n1 = m1.Lvar(), n2 =m2.Lvar();
22  if(n1 <0 && n2>0) return false;
23  if(n2 <0 && n1>0) return true;
24 
25  int dm1=0,dm2=0,firstdiff=0,tmpdeg1,tmpdeg2;
26  int n = std::max(n1,n2);
27  for(int i=0;i<=n;i++)
28  {
29  tmpdeg1=m1.GetDegree(i);
30  tmpdeg2=m2.GetDegree(i);
31  if(tmpdeg1>tmpdeg2 && firstdiff==0) firstdiff=1;
32  if(tmpdeg2>tmpdeg1 && firstdiff==0) firstdiff=-1;
33  dm1+=tmpdeg1;
34  dm2+=tmpdeg2;
35  }
36  if (dm1 < dm2) return false;
37  else if (dm1 > dm2) return true;
38  return (firstdiff==1);
39 
40 }
41 
42 template <class M>
43 bool Rlex<M>::operator() (const M & m1, const M & m2) {
44  return less(m1,m2);
45 }
46 
47 //template <class T1,class T2>
48 //bool operator< (const Monom<T1,T2> & m1, const Monom<T1,T2> & m2) {
49 // return Rlex<Monom<T1,T2> >::less(m1,m2);
50 //}
51 
52 #endif // //_Rlex_H_
53 
#define max(a, b)
Definition: alp_f2c.H:167
Definition: Rlex.hpp:13
static bool less(const M &, const M &)
Definition: Rlex.hpp:20
bool operator()(const M &, const M &)
Definition: Rlex.hpp:43
MSKint32t MSKint32t MSKint32t i
Definition: mosek.h:2278
Home  |  Download & InstallContributions