groebspa.red 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. module groebspa;
  2. % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
  3. % Manipulation of subspaces .
  4. % A subspace among the variables is described by an exponent vector
  5. % with only zeroes and ones . It terminates with the last
  6. % one . It may be null(nil).
  7. symbolic procedure vevunion(e1,e2);
  8. begin scalar x,y;y:=vevunion1(e1,e2);
  9. x:=reverse y;if car x = 1 then return y;
  10. while x and car x = 0 do x:=cdr x;return reversip x end;
  11. symbolic procedure vevunion1(e1,e2);
  12. if vdpsubspacep(e1,e2)then e2 else
  13. if vdpsubspacep(e2,e1)then e1 else
  14. if car e1 neq 0 or car e2 neq 0 then 1 . vevunion1(cdr e1,cdr e2)else
  15. 0 . vevunion1(cdr e1,cdr e2);
  16. symbolic procedure vdpsubspacep(e1,e2);
  17. % Test if e1 describes a subspace from e2 .
  18. if null e1 then t else
  19. if null e2 then vdpspacenullp e1 else
  20. if car e1 > car e2 then nil else
  21. if e1 = e2 then t else vdpsubspacep(cdr e1,cdr e2);
  22. symbolic procedure vdporthspacep(e1,e2);
  23. % Test if e1 and e2 describe orthogonal spaces(no intersection).
  24. if null e1 or null e2 then t else
  25. if car e2 = 0 or car e1 = 0 then vdporthspacep(cdr e1,cdr e2)else nil;
  26. symbolic procedure vdpspacenullp e1;
  27. % Test if e1 describes an null space .
  28. if null e1 then t else
  29. if car e1 = 0 then vdpspacenullp cdr e1 else nil;
  30. symbolic procedure vdpspace p;
  31. % Determine the variables of the polynomial .
  32. begin scalar x,y;
  33. if vdpzero!? p then return nil;
  34. x:=vdpgetprop(p,'subroom);
  35. if x then return x;
  36. x:=vevunion(nil,vdpevlmon p);
  37. y:=vdpred p;
  38. while not vdpzero!? y do
  39. <<x:=vevunion(x,vdpevlmon y);y:=vdpred y>>;
  40. vdpputprop(p,'subroom,x);
  41. return x end;
  42. symbolic procedure vdpunivariate!? p;
  43. if vdpgetprop(p,'univariate)then t
  44. else begin scalar ev;integer n;
  45. ev:=vdpevlmon p;
  46. for each x in ev do
  47. if not(x = 0)then n:=n #+ 1;
  48. if not(n = 1)then return nil;
  49. ev:=vdpspace p;
  50. for each x in ev do
  51. if not(x = 0)then n:=n #+ 1;
  52. if not(n = 1)then return nil;
  53. vdpputprop(p,'univariate,t);
  54. return t end;
  55. endmodule;;end;