groebres.red 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. module groebres;
  2. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  3. %
  4. % optimization of h-Polynomials by resultant calculation and
  5. % factorization
  6. %
  7. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  8. fluid '(!*trgroeb );
  9. % the resultant is calculated from a h-polynomial and its predecessor
  10. % if both are bivariate in the same variables and if these variables
  11. % are the last ones in vdpvars*.
  12. symbolic procedure groebTestResultant(h1,h2,lv);
  13. begin scalar v1,hlist;
  14. v1 := indexcpl(vevsum0(lv,h1),1);
  15. if GroebRescheck!?(2,v1,lv)
  16. and indexcpl(vevsum0(lv,h2),1)=v1
  17. then hlist :=
  18. reverse vdplsort
  19. groebHlistfromresultant
  20. (h1,h2,cadr reverse vdpvars!*)
  21. else
  22. if GroebRescheck1!?(2,v1,lv)
  23. and indexcpl(vevsum0(lv,h2),1)=v1
  24. then hlist :=
  25. reverse vdplsort
  26. groebHlistfromresultant
  27. (h1,h2,caddr reverse vdpvars!*);
  28. if null hlist then return nil;
  29. return 'RESULTANT .
  30. for each x in hlist collect list(h2,vdpEnumerate x);
  31. end;
  32. symbolic procedure groebHlistfromresultant(h1,h0,x);
  33. % new h-polynomial calculation: calculate
  34. % the resultant of the two distributive polynomials h1 and h0
  35. % with respect to x.
  36. begin scalar ct00,hh,hh1,hs2;
  37. ct00:= time();
  38. hh:= vdpSimpCont groebResultant(h1,h0,x);
  39. if !*trgroeb then <<terpri();
  40. printb 57;
  41. prin2t " *** the resultant from ";
  42. vdpprint h1;
  43. prin2t " *** and";
  44. vdpprint h0;
  45. prin2t " *** is";
  46. vdpprint hh;
  47. printb 57;
  48. terprit 4 >>;
  49. hs2:= nil;
  50. if not vdpzero!? hh then
  51. << hh1:= vdp2a vdprectoint(hh,vdplcm hh);
  52. hh1:= fctrf !*q2f simp hh1;
  53. if cdr hh1 and cddr hh1 then
  54. hs2:= for each p in cdr hh1 collect a2vdp prepf car p;
  55. if !*trgroeb and hs2 then
  56. <<prin2 " factorization of resultant successful:";
  57. terprit 2;
  58. for each x in hs2 do vdpprint x;
  59. terprit 2;
  60. ct00:= time() - ct00;
  61. prin2 " time for factorization:"; prin2 ct00;
  62. terpri() >>;
  63. >>;
  64. return hs2
  65. end;
  66. symbolic procedure groebResultant(p1,p2,x);
  67. begin scalar q1,q2,q;
  68. q1:=vdp2a vdprectoint(p1,vdplcm p1);
  69. q2:=vdp2a vdprectoint(p2,vdplcm p2);
  70. q:=a2vdp prepsq simpresultant list(q1,q2,x);
  71. return q;
  72. end;
  73. symbolic procedure GroebRescheck!?(a,h1,vl);
  74. length h1 = a and car h1 = vl - 1;
  75. symbolic procedure GroebRescheck1!?(a,h1,vl);
  76. length h1 = a and car h1 = vl - 2 and cadr h1 = vl - 1;
  77. endmodule;
  78. end;