synaps/mpol/Ilex.h

00001 /*********************************************************************
00002 *      This file is part of the source code of SYNAPS software.      *
00003 *      (C) B. Mourrain, GALAAD, INRIA                                *
00004 **********************************************************************
00005 History: 
00006         07/2001 created I.Z. Emiris
00007         04/2002 updated I.Z. Emiris
00008 **********************************************************************/
00009 #ifndef SYNAPS_MPOL_ILEX_H
00010 #define SYNAPS_MPOL_ILEX_H
00011 
00012 #include <synaps/init.h>
00013 
00014 __BEGIN_NAMESPACE_SYNAPS
00015 
00021 struct Ilex 
00022 {
00023   template <class M>
00024   static bool less (const M &, const M &);
00025   template <class M>
00026   bool operator() (const M & m1, const M & m2) const {return less(m1,m2);}
00027 };
00028  
00029 template <class M>
00030 inline bool Ilex::less(const M & m1, const M & m2) {
00031    int n1 = m1.nvars(), n2 =m2.nvars();
00032    int i = 0, mx = std::max(n1,n2);
00033         
00034 //    if(n1 <0 && n2>0) return true;
00035 //    if(n2 <0 && n1>0) return false;
00036 
00037    while( m1[i] == m2[i] && i<=mx) i++;
00038    if(i >mx) 
00039      return false;     
00040    else 
00041      return (m1[i]< m2[i]);
00042 }
00043 
00044 
00045 __END_NAMESPACE_SYNAPS
00046 
00047 #endif // SYNAPS_MPOL_ILEX_H
00048 

SYNAPS DOCUMENTATION
logo