reord.red 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. module reord; % Functions for reordering standard forms.
  2. % Author: Anthony C. Hearn.
  3. % Copyright (c) 1990 The RAND Corporation. All rights reserved.
  4. fluid '(alglist!* kord!* ncmp!*);
  5. alglist!* := nil . nil; % This is first module that uses this.
  6. symbolic procedure reordsq u;
  7. % Reorders a standard quotient so that current kernel order is used.
  8. reorder numr u ./ reorder denr u;
  9. symbolic procedure reorder u;
  10. % Reorders a standard form so that current kernel order is used.
  11. % Note: this version does not reorder any sfs used as kernels.
  12. if domainp u then u
  13. else raddf(rmultpf(lpow u,reorder lc u),reorder red u);
  14. symbolic procedure raddf(u,v);
  15. % Adds reordered forms U and V.
  16. if null u then v
  17. else if null v then u
  18. else if domainp u then addd(u,v)
  19. else if domainp v then addd(v,u)
  20. else if peq(lpow u,lpow v)
  21. then (lpow u .* raddf(lc u,lc v)) .+ raddf(red u,red v)
  22. else if ordpp(lpow u,lpow v) then lt u . raddf(red u,v)
  23. else lt v . raddf(u,red v);
  24. symbolic procedure rmultpf(u,v);
  25. % Multiplies power U by reordered form V.
  26. if null v then nil
  27. else if domainp v or reordop(car u,mvar v) then !*t2f(u .* v)
  28. else (lpow v .* rmultpf(u,lc v)) .+ rmultpf(u,red v);
  29. symbolic procedure reordop(u,v);
  30. if ncmp!* and noncomp u and noncomp v then t else ordop(u,v);
  31. symbolic procedure kernel!-list u;
  32. % Converts u to a list of kernels, expanding lists in u.
  33. for each x in u join
  34. <<x:=reval x;
  35. if eqcar(x,'list) then kernel!-list cdr x else {!*a2k x}>>;
  36. symbolic procedure korder u;
  37. <<kord!* := if u = '(nil) then nil else kernel!-list u;
  38. rmsubs()>>;
  39. rlistat '(korder);
  40. symbolic procedure setkorder u;
  41. begin scalar v;
  42. v := kord!*;
  43. if u=v then return v;
  44. kord!* := u;
  45. alglist!* := nil . nil; % Since kernel order has changed.
  46. return v
  47. end;
  48. symbolic procedure updkorder u;
  49. % U is a kernel. Value is previous kernel order.
  50. % This function is used when it is necessary to give one kernel
  51. % highest precedence (e.g., when extracting coefficients), but not
  52. % change the order of the other kernels.
  53. begin scalar v,w;
  54. v := kord!*;
  55. w := u . delete(u,v);
  56. if v=w then return v;
  57. kord!* := w;
  58. alglist!* := nil . nil; % Since kernel order has changed.
  59. return v
  60. end;
  61. endmodule;
  62. end;