DistribPolys.mesa
Last Edited by: Arnon, June 10, 1985 4:19:22 pm PDT
DIRECTORY
Rope USING [ROPE],
Ascii,
IO USING [STREAM],
AlgebraClasses,
Variables;
DistribPolys: CEDAR DEFINITIONS
IMPORTS Ascii
= BEGIN OPEN AC: AlgebraClasses, VARS: Variables;
Types
DPolynomial: TYPE = LIST OF DTerm; -- Distributed rep
DTerm: TYPE = RECORD [
coefficient: REF,
degreeVector: DegreeVector
];
ZeroDPoly: DPolynomial = NIL;
DegreeVector: TYPE = LIST OF CARDINAL;
Distributed Polynomial IO
RatPolynomialFirstChar: PROC [c: CHAR] RETURNS [BOOL] ~ INLINE {
RETURN[Ascii.Digit[c] OR Ascii.Letter[c] OR c='- OR c='+]
};
TermCharProc: TYPE = PROC [char: CHAR] RETURNS [BOOL];
DollarProc: TermCharProc; -- RETURN[char='$]
RightBracketProc: TermCharProc; -- RETURN[char='] OR char=')]
DollarRope: Rope.ROPE; -- " $"
ReadDPoly: PROC [in: IO.STREAM, V: VARS.VariableSeq, coeffRing: AC.Structure, termCharProc: TermCharProc ← DollarProc] RETURNS [poly: DPolynomial, termChar: CHAR];
The polynomial is terminated by any char for which termCharProc returns TRUE. termChar is the particular terminating character for this polynomial. It has been read, i.e. removed from the in stream.
DPolyFromRope: PROC [in: Rope.ROPE, V: VARS.VariableSeq, coeffRing: AC.Structure, termCharProc: TermCharProc ← DollarProc] RETURNS [out: DPolynomial];
DPolyToRope: PROC [in: DPolynomial, V: VARS.VariableSeq, coeffRing: AC.Structure, termRope: Rope.ROPE ← DollarRope] RETURNS [out: Rope.ROPE];
termRope is written following the polynomial.
WriteDPoly: PROC [in: DPolynomial, V: VARS.VariableSeq, coeffRing: AC.Structure, out: IO.STREAM, termRope: Rope.ROPE ← DollarRope];
DPReverse: PROC [list: DPolynomial] RETURNS[val: DPolynomial];
Degree Vectors
DVInsertVariablePower: PROC [varIndex, exponent: CARDINAL, inDegreeVec: DegreeVector] RETURNS [ok: BOOL, outDegreeVec: DegreeVector];
DVCompare: PROC [dv1, dv2: DegreeVector] RETURNS [ [-1..1] ];
DVDegree: PROC [degreeVec: DegreeVector, numVars: CARDINAL] RETURNS [degree: CARDINAL];
DVRemoveMainVariablePower: PROC [in: DegreeVector, numVars: CARDINAL] RETURNS [out: DegreeVector];
DVAddMainVariablePower: PROC [in: DegreeVector, varIndex, exponent: CARDINAL] RETURNS [out: DegreeVector];
DVCons4: PROC [x1, x2, x3, x4: CARDINAL, degreeVec: DegreeVector] RETURNS [DegreeVector];
DVNconc: PROC [l1, l2: DegreeVector] RETURNS [DegreeVector];
DVReverse: PROC [list: DegreeVector] RETURNS[val: DegreeVector];
END.