DIRECTORY Polynomial USING [Ref], Rope USING [ROPE]; MultiPolynomial: CEDAR DEFINITIONS ~ BEGIN Ref: TYPE ~ REF MultiPolRec; MultiPolSequence: TYPE ~ RECORD [ pols: SEQUENCE length: NAT OF Ref]; MultiPolRec: TYPE ~ RECORD [terms: SEQUENCE length: NAT OF Monomial]; Monomial: TYPE ~ RECORD[ coefficient: REAL, vars: REF PoweredVariableSequence]; PoweredVariableSequence: TYPE ~ RECORD [ varList: SEQUENCE numVars: NAT OF PoweredVariable]; PoweredVariable: TYPE ~ RECORD[ variable: ATOM, degree: INTEGER]; EvaluationBindings: TYPE ~ LIST OF EvaluationBinding; EvaluationBinding: TYPE ~ RECORD[ variable: ATOM, value: REAL]; SubstitutionBindings: TYPE ~ LIST OF SubstitutionBinding; SubstitutionBinding: TYPE ~ RECORD[ variable: ATOM, replacement: Ref]; TSUBindings: TYPE ~ LIST OF TSUBinding; TSUBinding: TYPE ~ RECORD[ variable: ATOM, replacement: Polynomial.Ref]; Error: ERROR [reason: ErrorCode]; ErrorCode: TYPE ~ { NotUnivariate, NotConstant, BadFormat, UnsubstitutedVariables, BadVariableName, InternalError }; RefFromRope: PROC [rope: Rope.ROPE] RETURNS [Ref]; UnivariateFromRef: PROC [a: Ref, var: ATOM] RETURNS [Polynomial.Ref]; RefFromUnivariate: PROC [pol: Polynomial.Ref, var: ATOM] RETURNS [Ref]; RealFromRef: PROC [a: Ref] RETURNS [REAL]; RopeFromRef: PROC [a: Ref] RETURNS [Rope.ROPE]; Sum: PROC [a, b: Ref] RETURNS [Ref]; Difference: PROC [a, b: Ref] RETURNS [Ref]; Power: PROC [a: Ref, n: NAT] RETURNS [Ref]; Product: PROC [a, b: Ref] RETURNS [Ref]; Scale: PROC [p: Ref, c: REAL] RETURNS [Ref]; Differentiate: PROC [a: Ref, var: ATOM] RETURNS [Ref]; Degree: PROC [a: Ref] RETURNS [NAT]; Evaluate: PROC [a: Ref, variable: ATOM, value: REAL] RETURNS [Ref]; EvaluateList: PROC [a: Ref, bindings: EvaluationBindings] RETURNS [Ref]; TotallyEvaluate: PROC [a: Ref, bindings: EvaluationBindings] RETURNS [REAL]; Substitute: PROC [a: Ref, variable: ATOM, replacement: Ref] RETURNS [Ref]; SubstituteList: PROC [a: Ref, bindings: SubstitutionBindings] RETURNS [Ref]; TotallySubstituteUnivariates: PROC [a: Ref, bindings: TSUBindings] RETURNS [Polynomial.Ref]; END. ,MultiPolynomial.mesa Multivariate polynomials with real coefficients. Copyright (C) 1986 by Xerox Corporation. All rights reserved. James Rauen August 14, 1986 6:07:38 pm PDT Type declarations Errors tried to make a univariate polynomial from a Ref that had other variables tried to make a nonconstant polynomial into a real tried to make a Ref from an incorrectly formatted rope didn't substitute for all the variables when you should have tried to use a variable name which was not alphabetic or was longer than 1 char track down the implementor and kill him Conversions to and from other representations Obtains a Ref from the rope representation, according to the grammar in the Rope Representation section below. If the representation is not valid, Error[BadFormat] is raised. Note: this is usually the easiest way to create a MultiPolynomial. Warning: "e" notation doesn't work (e is treated as a variable). Returns a univariate polynomial. If variables other than var occur in a, raises Error[NotUnivariate]. Returns a Ref from a univariate polynomial, using var for the variable. If var is not a legal variable name, raises Error[BadVariableName]. Returns the real value of a. If a is not a constant, raises Error[NotConstant]. Returns a Rope representation of the polynomial. Operations on MultiPols Returns the sum of the two polynomials. Returns the difference of the two polynomials. Returns the nth power of a. Returns the product of the two polynomials. Returns the product of a and c. Returns the derivative of a with respect to var. Returns the degree of a. Substitution Mechanisms Substitutes real value for variable in a and returns the resulting polynomial. Substitutes real values for variables in a and returns the resulting polynomial. Substitutes real values for all variables in a and returns the resulting real value. If unsubstituted variables remain in a, Error[UnsubstitutedVariables] is raised. Substitutes replacement for variable in a and returns the resulting polynomial. Substitutes replacements for variables in a and returns the resulting polynomial. Completely substitutes univariate polynomials into a. If unsubstituted variables remain in a, Error[UnsubstitutedVariables] is raised. Rope representation grammar Grammar: ropeRepresentation ::= leadingTerm | leadingTerm moreTerms leadingTerm ::= term | sign term moreTerms ::= sign term | sign term moreTerms sign ::= + | - term ::= coefficient | poweredVariables | coefficient poweredVariables coefficient ::= string representation of REAL poweredVariables ::= poweredVariable | poweredVariable poweredVariables poweredVariable ::= variable | variable ^ exponent variable ::= a..z | A..Z exponent ::= string representation of NAT Note that whitespace is ignored. Examples: "-x^2-y^2-z^2+2" "xyzzy - 3Ab^2c^2b^3" "+2y - 4y" "-6.170" Κ΄˜™J™0J™>J™*J™—Icode˜šΟk ˜ Kšœ œ˜Kšœœœ˜—K˜KšΠlnœœ œ˜*K™šž™K˜Kšœœœ ˜šœœœ˜!Kšœœ œœ˜#—Kš œ œœ œ œœ ˜Ešœ œœ˜Kšœ œ˜Kšœœ˜#—šœœœ˜(Kšœ œ œœ˜3—šœœœ˜Kšœ œ˜Kšœœ˜—Kšœœœœ˜5šœœœ˜!Kšœ œ˜Kšœœ˜ —Kšœœœœ˜9šœœœ˜#Kšœ œ˜Kšœ˜—Kšœ œœœ ˜'Kšœ œœ œ˜H—K™šž™K™KšΟnœœ˜!šœ œ˜˜K™I—˜ K™2—˜ K™7—˜K™<—˜K™O—˜ K™'—K˜—K˜—K™šž-™-K™šŸ œœ œœ˜2K™΅K™—šŸœœœœ˜EK™fK™—šŸœœœœ˜GK™ŒK˜—šŸ œœ œœ˜*K™PK˜—šŸ œœ œœ˜/K™0K™——K™šž™K™šŸœœ œ˜$K™'K˜—šŸ œœ œ˜+K™.K˜—š Ÿœœ œœ˜+K™K˜—šŸœœ œ˜(K™+K˜—šŸœœ œœ˜,Kšœ™K™—šŸ œœœœ˜6K™0K™—šŸœœ œœ˜$K™K™——K™šž™K™š Ÿœœœ œœ˜CK™NK˜—šŸ œœ(œ˜HK™PK˜—šŸœœ(œœ˜LK™¦K˜—šŸ œœœœ˜JK™OK™—šŸœœ*œ˜LK™QK™—šŸœœ!œ˜\K™‡—K˜—K™šž™K™™Ibody™:L™ L™-L™L™FLšœΟiΠik™-L™GL™2Lšœ   ™Lšœ  ‘™)Lš‘ ™ L™—™ K™K™K™K™ K™K™——K˜Kšœ˜—…—&