3.4 Summarizing example: transmission of a sparse recursive polynomial

The following example combines `MP_RecUnion`

, `MP_Struct`

,
recursive, and user-defined type specifications.
The considered data structure is a recursive representation of a sparse
polynomial.
One possible declaration looks like:

union SparseRecPoly { Rational_t; // coefficient - prototype index 0 struct inner_poly{ // prototype index 1 MP_String_t; // varname MP_Uint32_t; // exponent union SparseRecPoly *; // multiplic subpoly union SparseRecPoly *; // additive subpoly }; };where

`Rational_t`

is supposed to be a previously defiend type
representing a rational number.

The sample data is:

`9876321098x^4(y+2/3) + x^2 = x^4 + x^2`

` *`

` (y + 2/3)`

` *`

` 9876321098`

Its encoding in MP is shown in the usual table form in figure
11 and as a source-code fragment using the MP API
in figure 12.

Based on the recursive poly example and the rules governing meta
operator type specifications, it is easy to develop the encodings of
more complex polynomial data, such as arrays or matrices of
polynomials, or the generators of a polynomial ideal. In these cases,
the top-level Cop:Poly::SparseRecPoly:1 operator of the example above
appears as a common meta operator in the TypeSpec of the
top-level enclosing operator and the rest of the type
specification is exactly as above. As a last example, we show how this
is accomplished in figure 13.