synaps/mpol/Vlex.h

00001 /*********************************************************************
00002 *      This file is part of the source code of SYNAPS kernel.        *
00003 *   Author(s): B. Mourrain, GALAAD, INRIA                            *
00004 **********************************************************************
00005 History: 
00006 $Id: Vlex.h,v 1.1 2005/07/11 11:17:56 mourrain Exp $
00007 **********************************************************************/
00008 #ifndef SYNAPS_MPOL_VLEX_H
00009 #define SYNAPS_MPOL_VLEX_H
00010 
00011 #include <synaps/init.h>
00012 
00013 __BEGIN_NAMESPACE_SYNAPS
00014 
00015 
00024 struct Vlex {
00025   template <class M> 
00026   static bool less(const M &, const M &);
00027   template <class M> 
00028   bool operator() (const M & m1, const M & m2) const {return less(m1,m2);}
00029 };
00030  
00031 template <class M>
00032 bool Vlex::less(const M & m1, const M & m2) {
00033    if (Degree(m1) > Degree(m2) ) return true;
00034    else if (Degree(m1) < Degree(m2)) return false;
00035    else {
00036      int n1 = m1.nvars(), n2 =m2.nvars();
00037      if(n1 <0 && n2>0) return false;
00038      if(n2 <0 && n1>0) return true;
00039      int n = max(n1,n2); 
00040      int i = max(n,0); 
00041      while(i>=0 && m1[i] == m2[i]) i--;
00042      if(i <0) 
00043        return false;
00044      else 
00045        return (m1[i]> m2[i]);
00046    }
00047 }
00048 
00049 
00050 __END_NAMESPACE_SYNAPS
00051 
00052 #endif // SYNAPS_MPOL_VLEX_H
00053 

SYNAPS DOCUMENTATION
logo