groebsor.red 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. module groebsor;
  2. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  3. %
  4. % Maintenance of lists of critical pairs(sorting etc .).
  5. %
  6. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  7. symbolic procedure groebcplistsortin(p,pl);
  8. % Distributive polynomial critical pair list sort. pl is a
  9. % special list for Groebner calculation, p is a pair.
  10. % Returns the updated list pl(p sorted into).
  11. if null pl then list p else
  12. <<groebcplistsortin1(p,pl);pl>>;
  13. symbolic procedure groebcplistsortin1(p,pl);
  14. % Destructive insert of ' p ' into nonnull ' pl ' .
  15. if not groebcpcompless!?(car pl,p)
  16. then <<rplacd(pl,car pl . cdr pl);rplaca(pl,p)>>
  17. else if null cdr pl then rplacd(pl,list p)
  18. else groebcplistsortin1(p,cdr pl);
  19. symbolic procedure groebcplistsort g;
  20. <<for each p in g do gg:=groebcplistsortin(p,gg);gg>> where gg=nil;
  21. symbolic procedure groebcplistmerge(pl1,pl2);
  22. % Distributive polynomial critical pair list merge. pl1 and pl2
  23. % are critical pair lists used in the Groebner calculation.
  24. % groebcplistmerge(pl1,pl2) returns the merged list.
  25. begin scalar cpl1,cpl2,sl;
  26. if null pl1 then return pl2;
  27. if null pl2 then return pl1;
  28. cpl1:=car pl1;cpl2:=car pl2;
  29. sl:=groebcpcompless!?(cpl1,cpl2);
  30. return(if sl then cpl1 . groebcplistmerge(cdr pl1,pl2)
  31. else cpl2 . groebcplistmerge(pl1,cdr pl2)) end;
  32. symbolic procedure groebcpcompless!?(p1,p2);
  33. % Compare 2 pairs wrt their sugar(=cadddr) or their lcm(=car).
  34. if !*gsugar then
  35. (if not(d=0)then d < 0 else if not(q=0)then q < 0 else
  36. vdpnumber(caddr p1)< vdpnumber(caddr p2)
  37. ) where d=cadddr p1 - cadddr p2,q=vevcomp(car p1,car p2)
  38. else vevcompless!?(car p1,car p2);
  39. endmodule;;end;