next up previous
Next: Zero Up: Design and Implementation of Previous: String expression of objects

   
CMOexpressions for numbers and polynomials

@../SSkan/plugin/cmotag.h
#define     CMO_MONOMIAL32  19
#define     CMO_ZZ          20 
#define     CMO_QQ          21
#define     CMO_ZERO        22
#define     CMO_DMS_GENERIC  24
#define     CMO_DMS_OF_N_VARIABLES  25
#define     CMO_RING_BY_NAME   26
#define     CMO_DISTRIBUTED_POLYNOMIAL 31
#define     CMO_RATIONAL       34


#define     CMO_INDETERMINATE  60
#define     CMO_TREE           61
#define     CMO_LAMBDA         62    /* for function definition */

In the sequel, we will explain on the groups CMObject/Basic, CMObject/Tree and CMObject/DistributedPolynomial.

The program bconv at OpenXM/src/ox_toolkit translates CMO expressions into binary formats. It is convinient to understand the binary formats explained in this section.

Example:

bash$ ./bconv
> (CMO_ZZ,123123);
00 00 00 14 00 00 00 01 00 01 e0 f3

Group CMObject/Basic requires CMObject/Primitive.
ZZ, QQ, Zero, Rational, Indeterminate,$\in$ CMObject/Basic.

\begin{eqnarray*}\mbox{Zero} &:& ({\tt CMO\_ZERO}) \\
& & \mbox{ --- Universal ...
...g}\, {\rm v}) \\
& & \mbox{ --- Variable name $v$\space . } \\
\end{eqnarray*}


Indeterminate is a name of a variable. v may be any sequence of bytes, but each system has its own restrictions on the names of variables. Indeterminates of CMO and internal variable names must be translated in one to one correspondence.

Group CMObject/Tree requires CMObject/Basic.
Tree, Lambda $\in$ CMObject/Basic.

\begin{eqnarray*}\mbox{Tree} &:& ({\tt CMO\_TREE}, {\sl Cstring}\, {\rm name},
...
... } \\
& & \mbox{ --- optional arguments come after leaves.} \\
\end{eqnarray*}


In many computer algebra systems, mathematical expressions are usually expressed in terms of a tree structure. For example, $\sin(x+e)$ is expressed as (sin, (plus, x, e)) as a tree. Tree may be expressed by putting the expression between SM_beginBlock and SM_endBlock, which are stack machine commands for delayed evaluation. (cf. { , } in PostScript). However it makes the implementation of stack machines complicated. It is desirable that CMObject is independent of OX stack machine. Therefore we introduce an OpenMath like tree representation for CMO Tree object. This method allows us to implement tree structure easily on individual OpenXM systems. Note that CMO Tree corresponds to Symbol and Application in OpenMath.

Lambda is used to define functions. It is the same as the Lambda expression in Lisp.

Example: the expression of sin(x+e).

(CMO_TREE, (CMO_STRING, "sin"), (CMO_STRING, "basic"),
    (CMO_LIST,[size=]1, 
        (CMO_TREE, (CMO_STRING, "plus"), (CMO_STRING, "basic"),
            (CMO_LIST,[size=]2, (CMO_INDETERMINATE,"x"),
                 (CMO_TREE,(CMO_STRING, "e"),  the base of natural logarithms
                            (CMO_STRING, "basic"))
        ))
    )
)

Example:

sm1> [(plus) (Basic) [(123).. (345)..]] [(class) (tree)] dc ::
Class.tree [    $plus$ , $Basic$ , [    123 , 345 ]  ]

Let us define a group for distributed polynomials. In the following DMS stands for Distributed Monomial System.

Group CMObject/DistributedPolynomials requires CMObject/Primitive, CMObject/Basic.
Monomial, Monomial32, Coefficient, Dpolynomial, DringDefinition, Generic DMS ring, RingByName, DMS of N variables $\in$ CMObject/DistributedPolynomials.


\begin{eqnarray*}\mbox{Monomial} &:& \mbox{Monomial32}\, \vert\, \mbox{Zero} \\ ...
... & & \mbox{ --- outord is the order of variables to output.} \\
\end{eqnarray*}


Note that it is possible to define DMS without RingByName and DMS of N variables.

In the following we describe how the above CMObjects are implemented on Asir and Kan.



 
next up previous
Next: Zero Up: Design and Implementation of Previous: String expression of objects
Nobuki Takayama 平成12年1月25日