[BACK]Return to graded_lexicographic_order.adb CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / PHC / Ada / Math_Lib / Polynomials

File: [local] / OpenXM_contrib / PHC / Ada / Math_Lib / Polynomials / graded_lexicographic_order.adb (download)

Revision 1.1.1.1 (vendor branch), Sun Oct 29 17:45:26 2000 UTC (23 years, 7 months ago) by maekawa
Branch: PHC, MAIN
CVS Tags: v2, maekawa-ipv6, RELEASE_1_2_3, RELEASE_1_2_2_KNOPPIX_b, RELEASE_1_2_2_KNOPPIX, RELEASE_1_2_2, RELEASE_1_2_1, HEAD
Changes since 1.1: +0 -0 lines

Import the second public release of PHCpack.

OKed by Jan Verschelde.

with Standard_Natural_Vectors;
with Standard_Integer_Vectors;

package body Graded_Lexicographic_Order is

-- FOR STANDARD NATURAL VECTORS :

  function "<" ( v1,v2 : Standard_Natural_Vectors.Vector ) return boolean is

    use Standard_Natural_Vectors;
    s1,s2 : natural;

  begin
    s1 := Sum(v1);
    s2 := Sum(v2);
    if s1 < s2
     then return true;
     elsif s1 > s2
         then return false;
         else if v1'first /= v2'first or else v1'last /= v2'last
               then raise CONSTRAINT_ERROR;
               else for i in v1'range loop
                      if v1(i) < v2(i)
                       then return true;
                       elsif v1(i) > v2(i)
                           then return false;
                      end if;
                    end loop;
                    return false;  -- v1 = v2
              end if;
    end if;
  end "<";

  function "<" ( v1,v2 : Standard_Natural_Vectors.Link_to_Vector )
               return boolean is

    use Standard_Natural_Vectors;

  begin
    if v2 = null
     then return false;
     elsif v1 = null
         then if Sum(v2) > 0
               then return true;
               else return false;
              end if;
         else return v1.all < v2.all;
    end if;
  end "<";

  function ">" ( v1,v2 : Standard_Natural_Vectors.Vector ) return boolean is

    use Standard_Natural_Vectors;

    s1,s2 : natural;

  begin
    s1 := Sum(v1);
    s2 := Sum(v2);
    if s1 < s2
     then return false;
     elsif s1 > s2
         then return true;
         else if v1'first /= v2'first or else v1'last /= v2'last
               then raise CONSTRAINT_ERROR;
               else for i in v1'range loop
                      if v1(i) < v2(i)
                       then return false;
                       elsif v1(i) > v2(i)
                           then return true;
                      end if;
                    end loop;
                    return false;  -- v1 = v2
              end if;
    end if;
  end ">";

  function ">" ( v1,v2 : Standard_Natural_Vectors.Link_to_Vector )
               return boolean is

    use Standard_Natural_Vectors;

  begin
    if v1 = null
     then return false;
     elsif v2 = null
         then if Sum(v1) > 0
               then return true;
               else return false;
              end if;
         else return v1.all > v2.all;
    end if;
  end ">";

-- FOR STANDARD INTEGER VECTORS :

  function "<" ( v1,v2 : Standard_Integer_Vectors.Vector ) return boolean is

    use Standard_Integer_Vectors;

    s1,s2 : integer;

  begin
    s1 := Sum(v1);
    s2 := Sum(v2);
    if s1 < s2
     then return true;
     elsif s1 > s2
         then return false;
         else if v1'first /= v2'first or else v1'last /= v2'last
               then raise CONSTRAINT_ERROR;
               else for i in v1'range loop
                      if v1(i) < v2(i)
                       then return true;
                       elsif v1(i) > v2(i)
                           then return false;
                      end if;
                    end loop;
                    return false;  -- v1 = v2
              end if;
    end if;
  end "<";

  function "<" ( v1,v2 : Standard_Integer_Vectors.Link_to_Vector )
               return boolean is

    use Standard_Integer_Vectors;

  begin
    if v2 = null
     then return false;
     elsif v1 = null
         then if Sum(v2) > 0
               then return true;
               else return false;
              end if;
         else return v1.all < v2.all;
    end if;
  end "<";

  function ">" ( v1,v2 : Standard_Integer_Vectors.Vector ) return boolean is

    use Standard_Integer_Vectors;

    s1,s2 : integer;

  begin
    s1 := Sum(v1);
    s2 := Sum(v2);
    if s1 < s2
     then return false;
     elsif s1 > s2
         then return true;
         else if v1'first /= v2'first or else v1'last /= v2'last
               then raise CONSTRAINT_ERROR;
               else for i in v1'range loop
                      if v1(i) < v2(i)
                       then return false;
                       elsif v1(i) > v2(i)
                           then return true;
                      end if;
                    end loop;
                    return false;  -- v1 = v2
              end if;
    end if;
  end ">";

  function ">" ( v1,v2 : Standard_Integer_Vectors.Link_to_Vector )
               return boolean is

    use Standard_Integer_Vectors;

  begin
    if v1 = null
     then return false;
     elsif v2 = null
         then if Sum(v1) > 0
               then return true;
               else return false;
              end if;
         else return v1.all > v2.all;
    end if;
  end ">";

end Graded_Lexicographic_Order;