greduo.red 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. module greduo;
  2. % Compute 'greduce' with several orders for the minimal polynomial.
  3. global'(gorder gorders greduce_result);
  4. share gorder;
  5. share gorders;
  6. share greduce_result;
  7. if null gorders then gorders:='(list revgradlex gradlex lex);
  8. symbolic procedure greduce!-orders!-eval u;
  9. % 'Greduce_orders(p,g)'; the result is the (minimal) reduction of 'p'
  10. % corresponding to the global variable '*orders', eventually '0'.
  11. begin scalar b,g,l,o,p,r,rr,s,ss,v,x;
  12. l:=length u;
  13. if 2>l or 3<l then
  14. rederr('groe4,1,"groe4 must have 2 or 3 parameters.");
  15. p:=reval car u;u:=cdr u;
  16. if eqexpr p then p:=!*eqn2a p;
  17. g:=reval car u;u:=cdr u;
  18. if not eqcar(g,'list) then
  19. rederr('groe4,2,"groe4: 2nd parameter must be a list.");
  20. for each gg in cdr g do
  21. if null x and eqexpr gg then x:=t;
  22. if x then
  23. g:='list.for each gg in cdr g collect
  24. if eqexpr gg then !*eqn2a gg else gg;
  25. if u then<<v:=reval car u;
  26. if not eqcar(v,'list) then
  27. rederr('groe4,3,"groe4: 3rd par. must be a list (or it must be omitted).")>>;
  28. v:='list.groebnervars(cdr g,v);
  29. for each oo in cdr gorders do
  30. if null b then
  31. <<o:=oo;oo:=if eqcar(oo,'list)then cdr oo else oo.nil;torder(v.oo);
  32. rr:=greduceeval{p,g};ss:=greduce!-orders!-size rr;
  33. if null r or ss<s then <<gorder:=o;r:=rr;s:=ss;greduce_result:=rr>>;
  34. if rr=0 then b:=t>>;return r end;
  35. put('greduce_orders,'psopfn,'greduce!-orders!-eval);
  36. symbolic procedure greduce!-orders!-size p;
  37. % Compute the size of the polynomial 'p'.
  38. if atom p then 1 else
  39. if eqcar(p,'expt)then(1+greduce!-orders!-size cadr p+2*x
  40. where x=if fixp caddr p and caddr p>1 and caddr p<30 then caddr p
  41. else 5*greduce!-orders!-size caddr p)else
  42. for each x in p sum greduce!-orders!-size x;
  43. endmodule;;end;