ncout.red 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. module nout; % Output of noncom polynomials.
  2. % Author: H. Melenk, ZIB Berlin, J. Apel, University of Leipzig
  3. % Copyright: Konrad-Zuse-Zentrum Berlin, 1994
  4. symbolic procedure nc_compact u;
  5. % write a polynomial in factored form.
  6. begin scalar vl,t1,t2,y,r,d,w;
  7. vl := intersection(kord!*,for each y in ncpi!-names!* collect car y);
  8. for each x in vl do
  9. <<y:=gensym();t1:=(x.y).t1;t2:=(y.x).t2>>;
  10. w:=simp u where !*factor=nil,!*factors=nil,!*exp=t;
  11. d:=denr w;
  12. r:=nc_compactr(numr w,reverse vl,t1,t2);
  13. return mk!*sq (r./d)end;
  14. symbolic procedure nc_compactr(u,vl,t1,t2);
  15. begin scalar x,xn,y,q,w,r,s;
  16. integer n,m;
  17. x:=car vl; vl := cdr vl;
  18. w:=nc_compactd u;
  19. n:=-1;
  20. loop:if null w then goto done;
  21. n:=n+1;
  22. xn:=if n=0 then 1 else x .** n .* 1 .+ nil;
  23. q:=nc_compactx(w,x,xn);
  24. w:=cdr q;q:=car q;
  25. if q then
  26. begin scalar !*factor,!*exp;
  27. if null vl or null cdr vl or 2>
  28. <<m:=0;for each y in vl do if smember(y,q) then m:=m+1;m>>
  29. then
  30. <<q:='plus.for each s in q collect prepf sublis(t1,s);
  31. !*factor:=t;
  32. q:=reorder sublis(t2,numr simp reval1(q,nil))>>
  33. else
  34. <<s:=nil; for each f in q do s:=addf(s,f);
  35. q:=nc_compactr(s,vl,t1,t2)>>;
  36. r:=addf(multf(q,xn),r)end;
  37. goto loop;
  38. done:return r end;
  39. symbolic operator nc_compact;
  40. symbolic procedure nc_compactd u;
  41. % convert standard form into list (=sum) of monomials.
  42. if domainp u then {u} else
  43. append(for each s in nc_compactd lc u collect lpow u .* s .+nil,
  44. red u and nc_compactd red u);
  45. symbolic procedure nc_compactx(u,x,xn);
  46. % Extract sum of terms which contain multiples of power xn. Divide xn out.
  47. begin scalar yes,no,w;
  48. for each r in u do
  49. if xn=1 and not smember(x,r) then yes:=r.yes
  50. else
  51. if (w:=quotf(r,xn)) and not smember(x,w) then yes:=w.yes else no:=r.no;
  52. return yes.no end;
  53. endmodule;;end;