alphas.red 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. module alphas;
  2. % Authors: A. C. Norman and P. M. A. Moore, 1981.
  3. fluid '(alphalist current!-modulus hensel!-growth!-size
  4. number!-of!-factors);
  5. %********************************************************************;
  6. %
  7. % This section contains access and update functions for the alphas.
  8. symbolic procedure get!-alpha poly;
  9. % Gets the poly and its associated alpha from the current alphalist
  10. % if poly is not on the alphalist then we force an error.
  11. begin scalar w;
  12. w:=assoc!-alpha(poly,alphalist);
  13. if null w then errorf list("Alpha not found for ",poly," in ",
  14. alphalist);
  15. return w
  16. end;
  17. symbolic procedure divide!-all!-alphas n;
  18. % Multiply the factors by n mod p and alter the alphas accordingly.
  19. begin scalar om,m,nn;
  20. om:=set!-modulus hensel!-growth!-size;
  21. nn:=modular!-number n;
  22. m:=modular!-expt(
  23. modular!-reciprocal nn,
  24. number!-of!-factors #- 1);
  25. alphalist:=for each a in alphalist collect
  26. (times!-mod!-p(nn,car a) . times!-mod!-p(m,cdr a));
  27. set!-modulus om
  28. end;
  29. symbolic procedure multiply!-alphas(n,oldpoly,newpoly);
  30. % Multiply all the alphas except the one associated with oldpoly
  31. % by n mod p. also replace oldpoly by newpoly in the alphalist.
  32. begin scalar om,faca;
  33. om:=set!-modulus hensel!-growth!-size;
  34. n:=modular!-number n;
  35. oldpoly:=reduce!-mod!-p oldpoly;
  36. faca:=get!-alpha oldpoly;
  37. alphalist:=delete(faca,alphalist);
  38. alphalist:=for each a in alphalist collect
  39. car a . times!-mod!-p(cdr a,n);
  40. alphalist:=(reduce!-mod!-p newpoly . cdr faca) . alphalist;
  41. set!-modulus om
  42. end;
  43. symbolic procedure multiply!-alphas!-recip(n,oldpoly,newpoly);
  44. % Multiply all the alphas except the one associated with oldpoly
  45. % by the reciprocal mod p of n. also replace oldpoly by newpoly.
  46. begin scalar om,w;
  47. om:=set!-modulus hensel!-growth!-size;
  48. n:=modular!-reciprocal modular!-number n;
  49. w:=multiply!-alphas(n,oldpoly,newpoly);
  50. set!-modulus om;
  51. return w
  52. end;
  53. endmodule;
  54. end;