DIPSWS(A,V,n)
[Distributive polynomial special write, subroutine. If n=1,then
A is a distributive rational polynomial, and if n=0 A is a
distributive integral polynomial. V is a variable list for A.
A printer page is assumed to carry 57 lines. Any main program using
DIPSWS should do an EJECT=1 first to calibrate line counting.]
const PSIZE=57.
safe G,g.
global G[80].
global g.
safe W[10].
safe r,i,s,j,x,y,m1,m2,b,z.
(1) [A=0.] EMPTOB; BLINES(1); if A==0 then
{ AWRITE(0); BLINES(2); return }.
(2) [A constant.] if V==() then { if n==1 then
RNWRIT(FIRST(A)) else IWRITE(FIRST(A)); BLINES(2);
return }.
(3) [Initialize for nonconstant polynomial.] r=LENGTH(V);
g=0; V'=V; for i=1,...,r do ADV(V';W[i],V');
A'=A; b=1; U=RNINT(1).
(4) [Determine whether next term will fit on current output line.]
if A'==() then go to 6;
FIRST2(A';c,d); if n==1 then { FIRST2(c;c1,c2); m1=4 }
else { c1=c; m1=3 }; IFCL2(c1;x,y);
if y==0 then m1=m1+1 else m1=m1+(y+2)/3;
if n==1 then { IFCL2(c2;x,y);
m1=m1+(y+2)/3 }; m2=0;
while d~=() do { ADV2(d;j,e,d); m2=m2+LENGTH(W[j]);
IFCL2(e;x,y); m2=m2+((y+2)/3)+1 };
if (RMARG-OPOS)<=(m1+m2)&OPOS>LMARG
then POLWR(PSIZE-3);
if (RMARG-OPOS)<=(m1+m2) then
{ CLOUT("term skipped -- requires ");
AWRITE(m1+m2); CLOUT(" columns. LMARG is ");
AWRITE(LMARG); CLOUT(", RMARG is ");
AWRITE(RMARG); emptob; A'=RED2(A'); go to 4 }.
(5) [Write next term.] ADV2(A';c,d,A');
if n==1 then { s=RNSIGN(c); c=RNABS(c) }
else { s=ISIGNF(c); c=IABSF(c) };
if s<0 then CWRITE('-') else if b==0
then CWRITE('+'); CWRITE(' '); b=0;
if n==1&RNCOMP(c,U)~=0 then
{ RNWRIT(c); CWRITE(' ') }
else if n==0&c~=1 then { IWRITE(c); CWRITE(' ') };
z=1; d=CINV(d);
while d~=() do { z=0; ADV2(d;e,j,d); CLOUT(W[j]);
if e>1 then { G[g+1]=OPOS+1; AWRITE(e); G[g+2]=OPOS;
g=g+2 }; CWRITE(' ') };
if z==1&((n==1&RNCOMP(c,U)==0)
|(n==0&c==1)) then
{ AWRITE(1); CWRITE(' ') }; go to 4.
(6) [Finish.] POLWR(PSIZE-3); return..