Computer Algebra Kit (c) 1993,00 by Comp.Alg.Objects. All Rights Reserved.

**Maturity Index:** Relatively mature

The example shows how to, destructively, convert from the variable dense into the variable sparse representation (see alsosparse = [Monomial scalar:[dense scalar]]; while (term = [dense removeTerm]) [sparse insertTerm:term];

The above example shows how to, destructively, convert from the variable sparse into the variable dense representation (see alsodense = [Monomial scalar:[sparse scalar] symbols:[sparse findSymbols]]; while (term = [sparse removeTerm]) [dense insertTerm:term];

The monomials in a variable sparse polynomial, are variable sparse. Likewise, the monomials in a variable dense polynomial, are variable dense. For a degree dense polynomial, the scalars of the monomials can be zero, while for a degree sparse polynomial they cannot.

+Creates a newscalar:aScalar

+Creates a newscalar:aScalarsymbols:aCltn

-Creates a new monomial with scalar equal to one and empty sequence of terms. The representation of the monomial is identical to that of the original monomial.empty

-Makes a copy of the terms of the monomial.copy

-Makes a deepCopy of the terms and the scalar of the monomial.deepCopy

- (int)Returns the intValue of the scalar of the monomial, if all terms are trivial. If not, generates an error message.intValue

-Returns a new monomial with a scalar whose value asintValue:(int)aValue

- (float)Returns the floatValue of the scalar of the monomial, if all terms are trivial. If not, generates an error message.floatValue

-Returns a new monomial with a scalar whose value asfloatValue:(float)aValue

-Returns, if all the terms in the monomial are trivial (have exponent equal to zero), a new reference to the scalar of the monomial. Otherwise returnsasScalar

-Returns, if the scalar of the monomial is equal to one and if the monomial contains exactly one term whose exponent is equal to one, a new reference to the symbol of that term. Otherwise returnsasSymbol

-Returns the scalar of the monomial.scalar

-Returns the trivial term.termOne

- (BOOL)Returns YES if the scalar of the monomial is equal to one.isMonic

- (BOOL)Returns YES if the terms of the monomial are variable sparse i.e., whether symbols raised to exponent zero are ignored and whether the collection of allowed symbols is dynamically adjusted when terms are inserted.isVariableSparse

- (BOOL)Returns YES if the terms of the monomial are variable dense i.e., whether symbols raised to exponent zero are stored and whether the collection of allowed symbols is fixed.isVariableDense

- (int)Returns the sum of the exponents of the terms in the monomial. Returns minus one if the monomial is equal to zero.degree

- (int)Returns the number of terms with non-zero exponent in the monomial. The total number of terms in a variable dense monomial is equal to the number of symbols. Note thatnumTerms

- (BOOL)Whether the monomial consists of a single term.isTerm

- (BOOL)Returns YES if the scalars and the terms of the monomial are equal to each other. The monomials must be in the same representation.isEqual:aMonomial

- (unsigned)Returns a hash value for the monomial.hash

-Returns a collection of symbols. If the monomial is variable dense, beware that some symbols may occur with a zero exponent in the monomial. If the monomial is variable sparse, this method returns an alphabetically sorted collection of all the symbols that occur in the monomial with non-zero exponent. Don' modify the collection returned by this method; do not attempt to insert new symbols, or change their order.symbols

- (BOOL)Should return YES if, when the monomialisOrderDegreeCompatible

- (BOOL)Should return YES if, when the monomialisOrderReverseDegreeCompatible

- (int)Compares the terms (symbols and exponents) of the monomials; the scalars of the monomials are not taken into account. Returns zero if the symbols and exponents of the terms are equal; returns -1 if the monomial is less thancompareTerms:aMonomial

If the monomials are variable dense, the first symbol in the collection of symbols is taken to be smaller than symbols with higher index in the array of symbols. This method compares with respect to the lexicographic order : it starts comparing the smallest symbols, and as long as exponents are equal, it works towards larger symbols (those at the end of the collection of symbols).

If the monomials are variable sparse, the method also compares lexicographically, but now the smallest symbol, is the one that is smallest with respect to Symbol's **compare:**. If the collection of symbols for a variable dense monomial is ordered alphabetically, the variable sparse and variable dense orderings coincide.

-Removes the leading term (first term with non-zero exponent) of the monomial or returnsremoveTerm

**See also:** leadingTerm, eachTerm

-InsertsinsertTerm:aTerm

If the coefficient of the term is zero, this method empties the sequence of terms and sets the scalar to zero, as if the monomial were multiplied by zero. Otherwise, the methods multiplies the coefficient of the term and the scalar of the monomial together, and, if the monomial doesn't contain a term with symbol equal to that of *aTerm*, the method inserts a (monic) term in the ordered sequence of terms. If there is a term in the same symbol, the method adds the exponent of *aTerm* to it.

-Returns a sequence of terms. The coefficient of each term is equal to one. The scalar of the monomial itself is obtained by sendingeachTerm

-Returns the leading term of the monomial i.e., the first term with a non-zero exponent. The coefficient of this term is equal to one. ReturnsleadingTerm

-zero

- (BOOL)Returns YES if the scalar object is zero.isZero

-negate

-double

-add:b

-subtract:b

-Returns a monomial with scalar equal to one and containing no (nontrivial) terms.one

- (BOOL)Whether there are only trivial terms and the scalar is equal to one.isOne

- (BOOL)isMinusOne

-square

-multiply:b

-Multiplies the scalar of the monomial bymultiplyScalar:s

-Divides scalar bydivideScalar:s

-Divides the scalars and the terms of the monomials. Returnsdivide:aMonomial

-Divides the terms of the monomials by the terms ofdivideTerms:aMonomial

-Returns a new monomial that is thegcd:aMonomial

-Returns a new monomial that is thelcm:aMonomial

-Returns a new monomial by sending afrobenius

-Returns a new monomial by sending afrobeniusInverse

- (BOOL)Whether the monomial prints a leading minus sign.printsLeadingSign

- (BOOL)Whether the monomial prints a sum.printsSum

- (BOOL)Whether the monomial prints a single product.printsProduct

-Prints the monomial toprintOn:(IOD)aFile