polyhelp.sa


Generated by gen_html_sa_files from ICSI. Contact gomes@icsi.berkeley.edu for details
 

class POLY_WRITE

class POLY_WRITE is -- formSw:=Reduce; wrCoeff(coeff:INTI, inout notFirst:BOOL, out flgSt:BOOL) is -- call: -- coeff: coefficient -- notFiest: true if it is not the first term -- return -- notFirst: always true -- flgSt: true if the coefficient is printed. -- So needen *, if some variable is follow after this. f:BOOL; if coeff<0.inti then f:=true; #LOGOUT+"-"; coeff:=-coeff; elsif notFirst then f:=false; #LOGOUT+"+"; end; flgSt:=(coeff>1.inti); if flgSt then #LOGOUT+coeff.str; end; notFirst:=true; end; wrVar( varChar:STR, deg:INT, last:BOOL, inout flgSt:BOOL) is pw1::="^{"; pw2::="}"; if deg=0 then if (~flgSt)and last then #LOGOUT+"1"; end; else if flgSt then #LOGOUT+"*"; end; flgSt:=true; #LOGOUT+varChar; if (deg<0)or(1<deg) then #LOGOUT+pw1+deg.str+pw2; end; end; end; end; -- class POLY_WRITE

class POLY_COEFF

class POLY_COEFF is AllocCP(maxDeg:INT):ARRAY{POLYS_INTI} pre (maxDeg>=0) is -- array of (x+1)^n pw::=POLYS_INTI::gen_func(|(1).inti,1.inti|); res:ARRAY{POLYS_INTI}:=#(maxDeg+1); res[0]:=POLYS_INTI::one; loop i::=1.upto!(maxDeg); res[i]:=res[i-1]*pw; end; return res; end; AllocCN(maxDeg:INT):ARRAY{POLYS_INTI} pre (maxDeg>=0) is -- array of (x-1)^n pw::=POLYS_INTI::gen_func(|(-1).inti,1.inti|); res:ARRAY{POLYS_INTI}:=#(maxDeg+1); res[0]:=POLYS_INTI::one; loop i::=1.upto!(maxDeg); res[i]:=res[i-1]*pw; end; return res; end; AllocCQ(maxDeg:INT):ARRAY{POLYS_INTI} pre (maxDeg>=0) is -- array of (x-2)^n pw::=POLYS_INTI::gen_func(|(-2).inti,1.inti|); res:ARRAY{POLYS_INTI}:=#(maxDeg+1); res[0]:=POLYS_INTI::one; loop i::=1.upto!(maxDeg); res[i]:=res[i-1]*pw; end; return res; end; end; -- class POLY_COEFF