groebres.red 2.9 KB

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