Borderbasix

SQVlex.hpp
Go to the documentation of this file.
1 /*********************************************************************
2 * This file is part of the source code of BORDERBASIX software. *
3 * (C) B. Mourrain, INRIA *
4 **********************************************************************
5 History:
6 $Id: SQVlex.hpp,v 1.1.1.1 2006/10/06 08:01:40 trebuche Exp $
7 **********************************************************************/
8 #ifndef _SQVlex_H_
9 #define _SQVlex_H_
10 
18 template <class M> struct SQVlex {
19  static bool less (const M &, const M &);
20  bool operator() (const M &, const M &);
21 };
22 
23 template <class M>
24 bool SQVlex<M>::less(const M & m1, const M & m2) {
25 
26  int n1 = m1.Lvar(), n2 =m2.Lvar();
27  int n = max(n1,n2);
28  //cout <<m1<<" "<<m2<<" "<<n1<<" "<<n2 <<endl;
29  if(n1 <0 && n2>0) return false;
30  if(n2 <0 && n1>0) return true;
31  if(n1 <0 && n2<0) return false;
32 
33  int d1=0,d2=0, k, c1, c2;
34  for(int i =0 ; i<= n1; i++) {c1 = max(d1,(k=m1.GetDegree(i)));d1+=k;}
35  for(int i =0 ; i<= n2; i++) {c2 = max(d2,(k=m2.GetDegree(i)));d2+=k;}
36 
37  if (c1 < c2) return false;
38  else if (c1 > c2) return true;
39  else if (d1 < d2) return false;
40  else if (d1 > d2) return true;
41  else {
42  int i=n;
43  while( m1.GetDegree(i) == m2.GetDegree(i) && i>=0) i--;
44  if(i <0)
45  return false;
46  else
47  return (m1.GetDegree(i)> m2.GetDegree(i));
48  }
49 }
50 
51 template <class M>
52 bool SQVlex<M>::operator()(const M & m1, const M & m2) {
53  return less(m1,m2);
54 }
55 
56 template <class M>
57 bool operator<(const M & m1, const M & m2) {return SQVlex<M>::less(m1,m2);}
58 #endif // _SQVlex_H_
59 
#define max(a, b)
Definition: alp_f2c.H:167
bool operator()(const M &, const M &)
Definition: SQVlex.hpp:52
Definition: SQVlex.hpp:18
MSKint32t k
Definition: mosek.h:2713
bool operator<(const M &m1, const M &m2)
Definition: SQVlex.hpp:57
static bool less(const M &, const M &)
Definition: SQVlex.hpp:24
MSKint32t MSKint32t MSKint32t i
Definition: mosek.h:2278
Home  |  Download & InstallContributions