groebspa.red 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. expr procedure vevUnion(e1,e2);
  8. begin scalar x,y;
  9. y := vevUnion1(e1,e2);
  10. x := reverse y;
  11. if car x = 1 then return y;
  12. while x and car x = 0 do x := cdr x;
  13. return reversip x;
  14. end;
  15. expr procedure vevUnion1(e1,e2);
  16. if vdpSubspacep(e1,e2) then e2
  17. else
  18. if vdpSubspacep(e2,e1) then e1
  19. else
  20. if car e1 neq 0 or car e2 neq 0 then 1 . vevUnion1(cdr e1,cdr e2)
  21. else
  22. 0 . vevUnion1(cdr e1,cdr e2);
  23. expr procedure vdpSubspacep(e1,e2);
  24. % test if e1 describes a subspace from e2
  25. if null e1 then t
  26. else
  27. if null e2 then vdpSpacenullp(e1)
  28. else
  29. if car e1 > car e2 then nil
  30. else
  31. if e1 = e2 then t
  32. else
  33. vdpSubspacep(cdr e1,cdr e2);
  34. expr procedure vdpOrthSpacep(e1,e2);
  35. % test if e1 and e2 describe orthogonal spaces(no intersection);
  36. if null e1 or null e2 then t
  37. else
  38. if car e2 = 0 or car e1 = 0
  39. then vdpOrthSpacep(cdr e1,cdr e2)
  40. else nil;
  41. expr procedure vdpSpacenullp(e1);
  42. % test if e1 describes an null space
  43. if null e1 then t
  44. else
  45. if car e1 = 0 then vdpSpacenullp(cdr e1)
  46. else nil;
  47. expr procedure vdpSpace(p);
  48. % determine the variables of the polynomial.
  49. begin scalar x,y;
  50. if vdpzero!? p then return nil;
  51. x := vdpGetProp(p,'SUBROOM);
  52. if x then return x;
  53. x := vevUnion(nil,vdpevlmon p);
  54. y := vdpred p;
  55. while not vdpzero!? y do
  56. <<x := vevUnion(x,vdpevlmon y);
  57. y := vdpred y>>;
  58. vdpPutProp (p,'SUBROOM,x);
  59. return x;
  60. end;
  61. symbolic procedure vdpUnivariate!?(p);
  62. if vdpGetProp(p,'UNIVARIATE) then t
  63. else begin scalar ev; integer n;
  64. ev := vdpevlmon p;
  65. for each x in ev do
  66. if not(x=0) then n := n#+1;
  67. if not(n=1) then return nil;
  68. ev := vdpSpace(p);
  69. for each x in ev do
  70. if not(x=0) then n := n#+1;
  71. if not(n=1) then return nil;
  72. vdpPutProp(p,'UNIVARIATE,t);
  73. return t;
  74. end;
  75. endmodule;
  76. end;