[BACK]Return to cmo-basic1.tex CVS log [TXT][DIR] Up to [local] / OpenXM / doc / OpenXM-specs

Annotation of OpenXM/doc/OpenXM-specs/cmo-basic1.tex, Revision 1.9

1.9     ! noro        1: %% $OpenXM: OpenXM/doc/OpenXM-specs/cmo-basic1.tex,v 1.8 2000/02/28 14:10:27 takayama Exp $
1.1       noro        2: //&jp \section{ 数, 多項式 の  CMO 表現 }
                      3: //&eg \section{ CMOexpressions for numbers and polynomials }
1.4       noro        4: \label{sec:basic1}
1.1       noro        5: /*&C
                      6: @../SSkan/plugin/cmotag.h
                      7: \begin{verbatim}
                      8: #define     CMO_MONOMIAL32  19
                      9: #define     CMO_ZZ          20
                     10: #define     CMO_QQ          21
                     11: #define     CMO_ZERO        22
                     12: #define     CMO_DMS_GENERIC  24
                     13: #define     CMO_DMS_OF_N_VARIABLES  25
                     14: #define     CMO_RING_BY_NAME   26
                     15: #define     CMO_DISTRIBUTED_POLYNOMIAL 31
                     16: #define     CMO_RATIONAL       34
                     17:
                     18:
                     19: #define     CMO_INDETERMINATE  60
                     20: #define     CMO_TREE           61
                     21: #define     CMO_LAMBDA         62    /* for function definition */
                     22: \end{verbatim}
                     23:
                     24: */
                     25:
                     26: /*&jp
1.4       noro       27: 以下, グループ CMObject/Basic, CMObject/Tree
1.1       noro       28: および CMObject/DistributedPolynomial
                     29: に属する CMObject の形式を説明する.
                     30:
1.5       noro       31: \noindent
                     32: {\tt OpenXM/src/ox\_toolkit} にある {\tt bconv} をもちいると
                     33: CMO expression を binary format に変換できるので,
                     34: これを参考にするといい.
1.1       noro       35: */
                     36: /*&eg
                     37: In the sequel, we will explain on the groups
1.4       noro       38: CMObject/Basic, CMObject/Tree
1.1       noro       39: and CMObject/DistributedPolynomial.
1.5       noro       40:
                     41: \noindent
                     42: The program {\tt bconv} at {\tt OpenXM/src/ox\_toolkit}
                     43: translates
                     44: CMO expressions into binary formats.
                     45: It is convinient to understand the binary formats explained in
                     46: this section.
1.1       noro       47: */
                     48:
1.5       noro       49: /*&C
                     50: \noindent Example:
                     51: \begin{verbatim}
                     52: bash$ ./bconv
                     53: > (CMO_ZZ,123123);
                     54: 00 00 00 14 00 00 00 01 00 01 e0 f3
                     55: \end{verbatim}
                     56: */
1.1       noro       57: /*&jp
                     58:
                     59: \bigbreak
                     60: \noindent
1.4       noro       61: Group CMObject/Basic requires CMObject/Primitive. \\
                     62: ZZ, QQ, Zero, Rational, Indeterminate,$\in$ CMObject/Basic. \\
1.1       noro       63: \begin{eqnarray*}
                     64: \mbox{Zero} &:& ({\tt CMO\_ZERO}) \\
                     65: & & \mbox{ --- ユニバーサルな ゼロを表す. } \\
                     66: \mbox{ZZ}         &:& ({\tt CMO\_ZZ},{\sl int32}\, {\rm f}, {\sl byte}\, \mbox{a[1]}, \ldots
1.9     ! noro       67: {\sl byte}\, \mbox{a[$|$f$|$]} ) \\
1.1       noro       68: &:& \mbox{ --- bignum をあらわす. a[i] についてはあとで説明}\\
1.9     ! noro       69: \mbox{QQ}        &:& ({\tt CMO\_QQ},
        !            70:                       {\sl int32}\, {\rm m}, {\sl byte}\, \mbox{a[1]}, \ldots, {\sl byte}\, \mbox{a[$|$m$|$]},
        !            71:                       {\sl int32}\, {\rm n}, {\sl byte}\, \mbox{b[1]}, \ldots, {\sl byte}\, \mbox{b[$|$n$|$]})\\
1.1       noro       72: & & \mbox{ --- 有理数 $a/b$ を表す. } \\
                     73: \mbox{Rational}        &:& ({\tt CMO\_RATIONAL}, {\sl CMObject}\, {\rm a}, {\sl CMObject}\, {\rm b}) \\
                     74: & & \mbox{ ---  $a/b$ を表す. } \\
                     75: \mbox{Indeterminate}        &:& ({\tt CMO\_INDETERMINATE}, {\sl Cstring}\, {\rm v}) \\
                     76: & & \mbox{ --- 変数名 $v$ . } \\
                     77: \end{eqnarray*}
                     78: */
                     79: /*&eg
                     80:
                     81: \bigbreak
                     82: \noindent
1.4       noro       83: Group CMObject/Basic requires CMObject/Primitive. \\
                     84: ZZ, QQ, Zero, Rational, Indeterminate,$\in$ CMObject/Basic. \\
1.1       noro       85: \begin{eqnarray*}
                     86: \mbox{Zero} &:& ({\tt CMO\_ZERO}) \\
                     87: & & \mbox{ --- Universal zero } \\
                     88: \mbox{ZZ}         &:& ({\tt CMO\_ZZ},{\sl int32}\, {\rm f}, {\sl byte}\, \mbox{a[1]}, \ldots
1.9     ! noro       89: {\sl byte}\, \mbox{a[$|$m$|$]} ) \\
1.1       noro       90: &:& \mbox{ --- bignum. The meaning of a[i] will be explained later.}\\
1.9     ! noro       91: \mbox{QQ}        &:& ({\tt CMO\_QQ},
        !            92:                       {\sl int32}\, {\rm m}, {\sl byte}\, \mbox{a[1]}, \ldots, {\sl byte}\, \mbox{a[$|$m$|$]},
        !            93:                       {\sl int32}\, {\rm n}, {\sl byte}\, \mbox{b[1]}, \ldots, {\sl byte}\, \mbox{b[$|$n$|$]})\\
1.1       noro       94: & & \mbox{ --- Rational number $a/b$. } \\
                     95: \mbox{Rational}        &:& ({\tt CMO\_RATIONAL}, {\sl CMObject}\, {\rm a}, {\sl CMObject}\, {\rm b}) \\
                     96: & & \mbox{ ---  Rational expression $a/b$. } \\
                     97: \mbox{Indeterminate}        &:& ({\tt CMO\_INDETERMINATE}, {\sl Cstring}\, {\rm v}) \\
                     98: & & \mbox{ --- Variable name $v$ . } \\
                     99: \end{eqnarray*}
                    100: */
                    101: /*&C
                    102:
                    103: */
                    104:
                    105: /*&jp
                    106: Indeterminate は変数名をあらわす.
                    107: v はバイト列であればなにを用いてもよいが,
                    108: システム毎に変数名として用いられるバイト列は制限がある.
                    109: 各システム xxx は任意の文字列を各システム固有の変数名へ1対1に変換できるように
                    110: 実装しないといけない.
                    111: (これを
                    112: {\tt Dx} は {\tt \#dx} と変換するなどの
                    113: escape sequence を用いて実現するのは, 無理があるようである.
                    114: テーブルを作成する必要があるであろう.)
                    115: */
                    116: /*&eg
                    117: Indeterminate is a name of a variable.
                    118: v may be any sequence of bytes, but each system has its own
                    119: restrictions on the names of variables.
                    120: Indeterminates of CMO and internal variable names must be translated
                    121: in one to one correspondence.
                    122: */
                    123:
                    124: /*&jp
                    125:
                    126: \noindent
1.4       noro      127: Group CMObject/Tree requires CMObject/Basic. \\
                    128: Tree, Lambda $\in$ CMObject/Basic. \\
1.1       noro      129: \begin{eqnarray*}
                    130: \mbox{Tree}        &:& ({\tt CMO\_TREE}, {\sl Cstring}\, {\rm name},
                    131:  {\sl Cstring}\, {\rm cdname}, {\sl List}\, {\rm leaves}) \\
                    132: & & \mbox{ --- 名前 name の定数または関数. 関数の評価はおこなわない. } \\
                    133: & & \mbox{ --- cdname は空文字列でなければ name の意味が説明されている }\\
                    134: & & \mbox{ --- OpenMath CD (content dictionary) の名前. } \\
                    135: \mbox{Lambda}        &:& ({\tt CMO\_LAMBDA}, {\sl List}\, {\rm args},
                    136:                           {\sl Tree} {\rm body}) \\
                    137: & & \mbox{ --- body を args を引数とする関数とする. } \\
                    138: & & \mbox{ --- optional な引数が必要なときは, leaves の後へつづける.} \\
                    139: \end{eqnarray*}
                    140: */
                    141: /*&eg
                    142:
                    143: \noindent
1.4       noro      144: Group CMObject/Tree requires CMObject/Basic. \\
                    145: Tree, Lambda $\in$ CMObject/Basic. \\
1.1       noro      146: \begin{eqnarray*}
                    147: \mbox{Tree}        &:& ({\tt CMO\_TREE}, {\sl Cstring}\, {\rm name},
                    148:  {\sl Cstring}\, {\rm cdname}, {\sl List}\, {\rm leaves}) \\
                    149: & & \mbox{ --- A function or a constant of name. Functions are not evaluated. } \\
                    150: & & \mbox{ --- cdname may be a null. If it is not null, it is the name of}\\
                    151: & & \mbox{ --- the OpenMath CD (content dictionary). } \\
                    152: \mbox{Lambda}        &:& ({\tt CMO\_LAMBDA}, {\sl List}\, {\rm args},
                    153:                           {\sl Tree} {\rm body}) \\
                    154: & & \mbox{ --- a function with the arguments body. } \\
                    155: & & \mbox{ --- optional arguments come after leaves.} \\
                    156: \end{eqnarray*}
                    157: */
                    158:
                    159: /*&jp
                    160: 数式を処理するシステムでは, Tree 構造が一般にもちいられる.
                    161: たとえば, $\sin(x+e)$ は,
                    162: {\tt (sin, (plus, x, e))}
                    163: なる Tree であらわすのが一般的である.
                    164: Tree の表現を スタックマシンのレベルでおこなうとすると,
                    165: {\tt ox\_BEGIN\_BLOCK}, {\tt ox\_END\_BLOCK} で評価を抑制するのが
                    166: 一つの方法である (cf. Postscript の {\tt \{ }, {\tt \} }).
                    167: たとえば上の方法では
                    168: {\tt x, e, plus, sin } を begin block, end block でかこめばよろしい.
                    169: われわれはスタックマシンの実装をなるべく簡単にするという立場をとりたい,
                    170: また数学オブジェクトを OX スタックマシンと CMObject を混在して表現したく
                    171: ない.
                    172: したがって,
                    173: Tree 構造は Open Math 風の表現をもちいた CMO を導入することにした.
                    174: またこのほうが, われわれの想定するシステム xxx において, Open XM 対応が
                    175: はるかに容易である.
                    176: なお, Tree は, Open Math では, Symbol, Application のメカニズムに相当する.
                    177: */
                    178: /*&eg
                    179: In many computer algebra systems, mathematical expressions are usually
                    180: expressed in terms of a tree structure.
                    181: For example,
                    182: $\sin(x+e)$ is expressed as
                    183: {\tt (sin, (plus, x, e))}
                    184: as a tree.
1.4       noro      185: Tree may be expressed by putting the expression between
1.3       noro      186: {\tt SM\_beginBlock} and {\tt SM\_endBlock}, which are
                    187: stack machine commands for delayed evaluation.
                    188: (cf. {\tt \{ }, {\tt \} } in PostScript).
                    189: However it makes the implementation of stack machines complicated.
                    190: It is desirable that CMObject is independent of OX stack machine.
                    191: Therefore we introduce an OpenMath like tree representation for CMO
1.7       noro      192: Tree object.
1.3       noro      193: This method allows us to implement tree structure easily
                    194: on individual OpenXM systems.
                    195: Note that CMO Tree corresponds to Symbol and Application in OpenMath.
1.1       noro      196: */
                    197:
                    198:
                    199: /*&C
                    200:
                    201: */
                    202: /*&jp
                    203: Lambda は関数を定義するための関数である.
                    204: Lisp の Lambda 表現と同じ.
1.3       noro      205: */
                    206: /*&eg
                    207: Lambda is used to define functions.
                    208: It is the same as the Lambda expression in Lisp.
                    209: */
1.1       noro      210:
                    211: \noindent
1.3       noro      212: //&jp 例: $sin(x+e)$ の表現.
                    213: //&eg Example: the expression of $sin(x+e)$.
1.1       noro      214: \begin{verbatim}
                    215: (CMO_TREE, (CMO_STRING, "sin"), (CMO_STRING, "basic"),
                    216:     (CMO_LIST,[size=]1,
                    217:         (CMO_TREE, (CMO_STRING, "plus"), (CMO_STRING, "basic"),
                    218:             (CMO_LIST,[size=]2, (CMO_INDETERMINATE,"x"),
1.6       noro      219: //&jp                  (CMO_TREE,(CMO_STRING, "e"),  自然対数の底
                    220: //&eg                  (CMO_TREE,(CMO_STRING, "e"),  the base of natural logarithms
                    221:                             (CMO_STRING, "basic"))
1.1       noro      222:         ))
                    223:     )
                    224: )
                    225: \end{verbatim}
                    226:
                    227: \noindent
                    228: Example:
                    229: \begin{verbatim}
                    230: sm1> [(plus) (Basic) [(123).. (345)..]] [(class) (tree)] dc ::
1.8       takayama  231: Class.tree [    $plus$ , $basic$ , [    123 , 345 ]  ]
1.1       noro      232: \end{verbatim}
                    233:
                    234:
                    235:
                    236: \bigbreak
1.3       noro      237: //&jp 次に, 分散表現多項式に関係するグループを定義しよう.
1.4       noro      238: /*&eg
                    239: Let us define a group for distributed polynomials. In the following
                    240: DMS stands for Distributed Monomial System.
                    241: */
1.1       noro      242:
                    243: \medbreak
                    244: \noindent
1.4       noro      245: Group CMObject/DistributedPolynomials requires CMObject/Primitive,
                    246: CMObject/Basic. \\
1.1       noro      247: Monomial, Monomial32, Coefficient, Dpolynomial, DringDefinition,
                    248: Generic DMS ring, RingByName, DMS of N variables $\in$
                    249: CMObject/DistributedPolynomials. \\
1.3       noro      250: /*&jp
1.1       noro      251: \begin{eqnarray*}
                    252: \mbox{Monomial} &:& \mbox{Monomial32}\, |\, \mbox{Zero} \\
                    253: \mbox{Monomial32}&:& ({\tt CMO\_MONOMIAL32}, {\sl int32}\, n,
                    254: {\sl int32}\, \mbox{e[1]}, \ldots,
                    255: {\sl int32}\, \mbox{e[n]}, \\
                    256: & & \ \mbox{Coefficient}) \\
                    257: & & \mbox{ --- e[i] で, $n$ 変数 monomial
                    258: $x^e = x_1^{e_1} \cdots x_n^{e_n}$ の各指数 $e_i$
                    259: をあらわす.} \\
                    260: \mbox{Coefficient}&:& \mbox{ZZ} | \mbox{Integer32} \\
                    261: \mbox{Dpolynomial}&:& \mbox{Zero} \\
                    262: & & |\ ({\tt CMO\_DISTRIBUTED\_POLYNOMIAL},{\sl int32} m, \\
                    263: & & \ \ \mbox{DringDefinition},
                    264: [\mbox{Monomial32}|\mbox{Zero}], \\
                    265: & &\ \
                    266: \{\mbox{Monomial32}\}) \\
                    267: & &\mbox{--- m はモノミアルの個数である.}\\
                    268: \mbox{DringDefinition}
                    269: &:& \mbox{DMS of N variables} \\
                    270: & & |\ \mbox{RingByName} \\
                    271: & & |\ \mbox{Generic DMS ring} \\
                    272: & & \mbox{ --- 分散表現多項式環の定義. } \\
                    273: \mbox{Generic DMS ring}
1.2       noro      274: &:& \mbox{({\tt CMO\_DMS\_GENERIC}) --- 新版はこちら}\\
1.1       noro      275: \mbox{RingByName}&:& ({\tt CMO\_RING\_BY\_NAME}, {\sl Cstring}\  {\rm s}) \\
                    276: & & \mbox{ --- 名前 s で, 格納された ring 定義.} \\
                    277: \mbox{DMS of N variables}
                    278: &:& ({\tt CMO\_DMS\_OF\_N\_VARIABLES}, \\
                    279: & & \ ({\tt CMO\_LIST}, {\sl int32}\, \mbox{m},
                    280: {\sl Integer32}\,  \mbox{n}, {\sl Integer32}\,\mbox{p} \\
                    281: & & \ \ [,{\sl object}\,\mbox{s}, {\sl Cstring}\,\mbox{c},
                    282:           {\sl List}\, \mbox{vlist},
                    283: {\sl List}\, \mbox{wvec}, {\sl List}\, \mbox{outord}]) \\
                    284: & & \mbox{ --- m はあとに続く要素の数} \\
                    285: & & \mbox{ --- n は変数の数, p は 標数} \\
                    286: & & \mbox{ --- s は ring の名前} \\
                    287: & & \mbox{ --- c は係数環, QQ, ZZ の場合は文字列で QQ, ZZ と書く.} \\
                    288: & & \mbox{ --- vlist は Indeterminate のリスト(新版). 多項式環の変数リスト} \\
                    289: & & \mbox{ --- wvec は order をきめる weight vector,} \\
                    290: & & \mbox{ --- outord は出力するときの変数順序.} \\
                    291: \end{eqnarray*}
1.3       noro      292: */
                    293: /*&eg
                    294: \begin{eqnarray*}
                    295: \mbox{Monomial} &:& \mbox{Monomial32}\, |\, \mbox{Zero} \\
                    296: \mbox{Monomial32}&:& ({\tt CMO\_MONOMIAL32}, {\sl int32}\, n,
                    297:                       {\sl int32}\, \mbox{e[1]}, \ldots,
                    298:                       {\sl int32}\, \mbox{e[n]}, \\
                    299:                  & & \ \mbox{Coefficient}) \\
                    300:                  & & \mbox{ --- e[i] is the exponent $e_i$ of the monomial
                    301:                       $x^e = x_1^{e_1} \cdots x_n^{e_n}$. } \\
                    302: \mbox{Coefficient}&:& \mbox{ZZ} | \mbox{Integer32} \\
                    303: \mbox{Dpolynomial}&:& \mbox{Zero} \\
                    304:                  & & |\ ({\tt CMO\_DISTRIBUTED\_POLYNOMIAL},{\sl int32} m, \\
                    305:                  & & \ \ \mbox{DringDefinition}, [\mbox{Monomial32}|\mbox{Zero}], \\
                    306:                  & &\ \
                    307:                     \{\mbox{Monomial32}\})  \\
                    308:                  & &\mbox{--- m is equal to the number of monomials.}\\
                    309: \mbox{DringDefinition}
                    310:                  &:& \mbox{DMS of N variables} \\
                    311:                  & & |\ \mbox{RingByName} \\
                    312:                  & & |\ \mbox{Generic DMS ring} \\
                    313:                  & & \mbox{ --- definition of the ring of distributed polynomials. } \\
                    314: \mbox{Generic DMS ring}
                    315:                  &:& ({\tt CMO\_DMS\_GENERIC}) \\
                    316: \mbox{RingByName}&:& ({\tt CMO\_RING\_BY\_NAME}, {\sl Cstring} s) \\
1.4       noro      317:                  & & \mbox{ --- The ring definition referred by the name ``s''.} \\
1.3       noro      318: \mbox{DMS of N variables}
                    319:                  &:& ({\tt CMO\_DMS\_OF\_N\_VARIABLES}, \\
                    320:                  & & \ ({\tt CMO\_LIST}, {\sl int32}\, \mbox{m},
                    321:                   {\sl Integer32}\,  \mbox{n}, {\sl Integer32}\, \mbox{p} \\
                    322:                  & & \ \ [,{\sl Cstring}\,\mbox{s}, {\sl List}\, \mbox{vlist},
                    323:                           {\sl List}\, \mbox{wvec}, {\sl List}\, \mbox{outord}]) \\
                    324:                  & & \mbox{ --- m is the number of elements.} \\
                    325:                  & & \mbox{ --- n is the number of variables, p is the characteristic} \\
                    326:                  & & \mbox{ --- s is the name of the ring, vlist is the list of variables.} \\
                    327:                  & & \mbox{ --- wvec is the weight vector.} \\
                    328:                  & & \mbox{ --- outord is the order of variables to output.} \\
                    329: \end{eqnarray*}
                    330: */
1.1       noro      331:
1.3       noro      332: /*&jp
1.1       noro      333: RingByName や DMS of N variables はなくても, DMS を定義できる.
                    334: したがって, これらを実装してないシステムで DMS を扱うものが
                    335: あってもかまわない.
                    336:
                    337: 以下, 以上の CMObject  にたいする,
                    338: xxx = asir, kan の振舞いを記述する.
1.3       noro      339: */
                    340: /*&eg
                    341: Note that it is possible to define DMS without RingByName and
                    342: DMS of N variables.
                    343:
                    344: In the following we describe how the above CMObjects
                    345: are implemented on Asir and Kan.
                    346: */
1.1       noro      347:
                    348: \subsection{ Zero}
1.3       noro      349: /*&jp
                    350: CMO では ゼロの表現法がなんとおりもあるが,
1.1       noro      351: どのようなゼロをうけとっても,
                    352: システムのゼロに変換できるべきである.
1.3       noro      353: */
                    354: /*&eg
                    355: Though CMO has various representations of zero,
                    356: each representation should be translated into zero
                    357: in the system.
                    358: */
1.1       noro      359:
                    360:
1.3       noro      361: //&jp \subsection{ 整数 ZZ }
                    362: //&eg \subsection{ Integer ZZ }
1.1       noro      363:
                    364: \begin{verbatim}
                    365: #define     CMO_ZZ          20
                    366: \end{verbatim}
                    367:
1.3       noro      368: /*&jp
                    369: この節ではOpen xxx 規約における任意の大きさの整数(bignum)の扱いについ
                    370: て説明する.  Open XM 規約における多重精度整数を表すデータ型 CMO\_ZZ は
                    371: GNU MPライブラリなどを参考にして設計されていて, 符号付き絶対値表現を用
                    372: いている.  (cf. {\tt kan/sm1} の配布ディレクトリのなかの {\tt
                    373: plugin/cmo-gmp.c}) CMO\_ZZ は次の形式をとる.
                    374: */
                    375: /*&eg
                    376: We describe the bignum (multi-precision integer) representation in OpenXM.
                    377: In OpenXM {\tt CMO\_ZZ} is used to represent bignum. Its design is similar
                    378: to that in GNU MP. (cf. {\tt plugin/cmo-gmp.c} in the {\tt kan/sm1}
                    379: distribution). CMO\_ZZ is defined as follows.
                    380: */
1.1       noro      381:
                    382: \begin{tabular}{|c|c|c|c|c|}
                    383: \hline
                    384: {\tt int32 CMO\_ZZ} & {\tt int32 $f$} & {\tt int32 $b_0$} & $\cdots$ &
                    385: {\tt int32 $b_{n}$} \\
                    386: \hline
1.3       noro      387: \end{tabular}
                    388:
                    389: /*&jp
                    390: $f$ は32bit整数である.  $b_0, \ldots, b_n$ は unsigned int32 である.
                    391: $|f|$ は $n+1$ である.  この CMO の符号は $f$ の符号で定める.  前述し
                    392: たように, 32bit整数の負数は 2 の補数表現で表される.
                    393:
                    394: Open xxx 規約では上の CMO は以下の整数を意味する. ($R = 2^{32}$)
                    395: */
                    396: /*&eg
                    397: $f$ is a 32bit integer. $b_0, \ldots, b_n$ are unsigned 32bit integers.
                    398: $|f|$ is equal to $n+1$.
                    399: The sign of $f$ represents that of the above CMO. As stated in Section
                    400: \ref{sec:basic0}, a negative 32bit integer is represented by
                    401: two's complement.
                    402:
                    403: In OpenXM the above CMO represents the following integer. ($R = 2^{32}$.)
                    404: */
1.1       noro      405:
                    406: \[
                    407: \mbox{sgn}(f)\times (b_0 R^{0}+ b_1 R^{1} + \cdots + b_{n-1}R^{n-1} + b_n R^n).
                    408: \]
1.3       noro      409:
                    410: /*&jp
                    411: {\tt int32} を network byte order で表現
                    412: しているとすると,例えば, 整数 $14$ は CMO\_ZZ で表わすと,
                    413: */
                    414: /*&eg
                    415: If we express {\tt int32} by the network byte order,
                    416: a CMO\_ZZ $14$ is expressed by
                    417: */
1.1       noro      418: \[
                    419: \mbox{(CMO\_ZZ, 1, 0, 0, 0, e)},
                    420: \]
1.3       noro      421: //&jp と表わす. これはバイト列では
1.4       noro      422: //&eg The corresponding byte sequence is
1.1       noro      423: \[
                    424: \mbox{\tt 00 00 00 14 00 00 00 01 00 00 00 0e}
                    425: \]
1.3       noro      426: //&jp となる.
1.1       noro      427:
                    428:
1.3       noro      429: //&jp なお ZZ の 0 ( (ZZ) 0 と書く ) は, {\tt (CMO\_ZZ, 00,00,00,00)} と表現する.
                    430: //&eg Note that CMO\_ZZ 0 is expressed by {\tt (CMO\_ZZ, 00,00,00,00)}.
1.1       noro      431:
                    432:
1.3       noro      433: //&jp \subsection{ 分散表現多項式 Dpolynomial }
                    434: //&eg \subsection{ Distributed polynomial Dpolynomial }
1.1       noro      435:
1.3       noro      436: /*&jp
1.1       noro      437: 環とそれに属する多項式は次のような考えかたであつかう.
                    438:
                    439: Generic DMS ring に属する元は,
                    440: 変数を $n$ 個持つ 適当な係数集合 $K$ を持つ多項式環 $K[x_1, \ldots, x_n]$
                    441: の元である.
                    442: 係数集合 $K$ がなにかは, 実際データを読み込み, Coefficient を見た段階で
                    443: わかる.
                    444: この環に属する多項式を CMO 形式でうけとった場合, 各サーバはその
                    445: サーバの対応する Object  に変換しないといけない.
                    446: この変換の仕方は, 各サーバ毎にきめる.
                    447:
                    448: Asir の場合は, $K[x_1, \ldots, x_n]$ の元は分散表現多項式に変換される.
                    449: \noroa{ でも, order はどうなるの? }
                    450:
                    451: {\tt kan/sm1} の場合は事情は複雑である.
                    452: {\tt kan/sm1} は, Generic DMS ring にあたる クラスをもたない.
                    453: つまり, Default で存在する, $n$ 変数の分散表現多項式環は存在しないわけである.
                    454: したがって, {\tt kan/sm1} では, DMS of N variables が来た場合,
                    455: これを CurrentRing の元として読み込む.  CurrentRing の変数の数が $n'$
                    456: で, $n' < n$ だと新しい多項式環を生成してデータを読み込む.
                    457: Order その他の optional 情報はすべて無視する.
                    458:
                    459: DMS の 2 番目のフィールドで,
                    460: Ring by Name を用いた場合, 現在の名前空間で変数 yyy に格納された ring object
                    461: の元として, この多項式を変換しなさいという意味になる.
                    462: {\tt kan/sm1} の場合, 環の定義は ring object として格納されており,
                    463: この ring object を 変数 yyy で参照することにより CMO としてうけとった
                    464: 多項式をこの ring の元として格納できる.
1.3       noro      465: */
1.1       noro      466:
1.3       noro      467: /*&eg
                    468: We treat polynomial rings and their elements as follows.
1.1       noro      469:
1.4       noro      470: Generic DMS ring is an $n$-variate polynomial ring $K[x_1, \ldots, x_n]$,
1.3       noro      471: where $K$ is some coefficient set. $K$ is unknown in advance
1.4       noro      472: and it is determined when coefficients of an element are received.
                    473: When a server has received an element in Generic DMS ring,
1.3       noro      474: the server has to translate it into the corresponding local object
                    475: on the server. Each server has its own translation scheme.
                    476: In Asir such an element are translated into a distributed polynomial.
                    477: In {\tt kan/sm1} things are complicated.
1.4       noro      478: {\tt kan/sm1} does not have any class corresponding to Generic DMS ring.
1.3       noro      479: {\tt kan/sm1} translates a DMS of N variables into an element of
                    480: the CurrentRing.
                    481: If the CurrentRing is $n'$-variate and $n' < n$, then
1.4       noro      482: an $n$-variate polynomial ring is newly created. Optional informations such as
1.3       noro      483: the term order are all ignored.
                    484:
1.4       noro      485: If RingByName ({\tt CMO\_RING\_BY\_NAME}, yyy)
1.3       noro      486: is specified as the second field of DMS,
                    487: it requests a sever to use a ring object whose name is yyy
                    488: as the destination ring for the translation.
                    489: This is done in {\tt kan/sm1}.
                    490: */
1.1       noro      491:
                    492: \medbreak \noindent
1.3       noro      493: //&jp {\bf Example}: (すべての数の表記は 16 進表記)
                    494: //&eg {\bf Example}: (all numbers are represented in hexadecimal notation)
1.1       noro      495: {\footnotesize \begin{verbatim}
                    496: Z/11Z [6 variables]
                    497: (kxx/cmotest.sm1) run
                    498: [(x,y) ring_of_polynomials ( ) elimination_order 11 ] define_ring ;
                    499: (3x^2 y). cmo /ff set ;
                    500: [(cmoLispLike) 1] extension ;
                    501: ff ::
                    502: Class.CMO CMO StandardEncoding: size = 52, size/sizeof(int) = 13,
                    503: tag=CMO_DISTRIBUTED_POLYNOMIAL
                    504:
                    505:   0  0  0 1f  0  0  0  1  0  0  0 18  0  0  0 13  0  0  0  6
                    506:   0  0  0  0  0  0  0  2  0  0  0  0  0  0  0  0  0  0  0  1
                    507:   0  0  0  0  0  0  0  2  0  0  0  3
                    508:
                    509: ff omc ::
                    510:  (CMO_DISTRIBUTED_POLYNOMIAL[1f],[size=]1,(CMO_DMS_GENERIC[18],),
                    511:   (CMO_MONOMIAL32[13],3*x^2*y),),
                    512: \end{verbatim} }
1.3       noro      513: /*&jp
                    514: $ 3 x^2 y$ は 6 変数の多項式環の 元としてみなされている.
                    515: */
                    516: /*&eg
                    517: $3 x^2 y$ is regarded as an element of a six-variate polynomial ring.
                    518: */
1.1       noro      519:
                    520:
1.3       noro      521: //&jp \subsection{再帰表現多項式の定義}
                    522: //&eg \subsection{Recursive polynomials}
1.1       noro      523:
                    524: \begin{verbatim}
                    525: #define CMO_RECURSIVE_POLYNOMIAL        27
                    526: #define CMO_POLYNOMIAL_IN_ONE_VARIABLE  33
                    527: \end{verbatim}
                    528:
1.4       noro      529: Group CMObject/RecursivePolynomial requires CMObject/Primitive, CMObject/Basic.\\
1.1       noro      530: Polynomial in 1 variable, Coefficient, Name of the main variable,
                    531: Recursive Polynomial, Ring definition for recursive polynomials
                    532: $\in$ CMObject/RecursivePolynomial \\
                    533:
1.3       noro      534: /*&jp
1.1       noro      535: \begin{eqnarray*}
                    536: \mbox{Polynomial in 1 variable} &:&
                    537: \mbox{({\tt CMO\_POLYNOMIAL\_IN\_ONE\_VARIABLE},\, {\sl int32}\, m, } \\
                    538: & & \quad \mbox{ Name of the main variable }, \\
                    539: & & \quad \mbox{ \{ {\sl int32} e, Coefficient \}} \\
                    540: & & \mbox{ --- m はモノミアルの個数. } \\
                    541: & & \mbox{ --- e, Coefficieint はモノミアルを表現している. } \\
                    542: & & \mbox{ --- 順序の高い順にならべる. 普通は巾の高い順.} \\
                    543: & & \mbox{ ---  e は 1変数多項式の巾をあらわす. } \\
                    544: \mbox{Coefficient} &:& \mbox{ ZZ} \,|\, \mbox{ QQ } \,|\,
                    545: \mbox{ integer32  } \,|\,
                    546: \mbox{ Polynomial in 1 variable } \\
                    547: & & \quad \,|\, \mbox{Tree} \,|\, \mbox{Zero} \,|\,\mbox{Dpolynomial}\\
                    548: \mbox{Name of the main variable } &:&
                    549: \mbox{ {\sl int32} v }   \\
                    550: & & \mbox{ --- v は 変数番号 (0 からはじまる) を表す. } \\
                    551: \mbox{Recursive Polynomial} &:&
                    552: \mbox{ ( {\tt CMO\_RECURSIVE\_POLYNOMIAL}, } \\
1.3       noro      553: & & \quad \mbox{ RringDefinition, } \\
1.1       noro      554: & & \quad
                    555: \mbox{ Polynomial in 1 variable}\, | \, \mbox{Coefficient}   \\
1.3       noro      556: \mbox{RringDefinition}
1.1       noro      557: & : &  \mbox{ {\sl List} v } \\
                    558: & & \quad \mbox{ --- v は, 変数名(indeterminate) のリスト. } \\
                    559: & & \quad \mbox{ --- 順序の高い順. } \\
                    560: \end{eqnarray*}
1.3       noro      561: */
                    562: /*&eg
                    563: \begin{eqnarray*}
                    564: \mbox{Polynomial in 1 variable} &:&
                    565: \mbox{({\tt CMO\_POLYNOMIAL\_IN\_ONE\_VARIABLE},\, {\sl int32}\, m, } \\
                    566: & & \quad \mbox{ Name of the main variable }, \\
                    567: & & \quad \mbox{ \{ {\sl int32} e, Coefficient \}} \\
1.4       noro      568: & & \mbox{ --- m is the number of monomials. } \\
                    569: & & \mbox{ --- A pair of e and Coefficient represents a monomial. } \\
1.3       noro      570: & & \mbox{ --- The pairs of e and Coefficient are sorted in the } \\
                    571: & & \mbox{ \quad decreasing order, usually with respect to e.} \\
                    572: & & \mbox{ ---  e denotes an exponent of a monomial with respect to } \\
                    573: & & \mbox{ \quad the main variable. } \\
                    574: \mbox{Coefficient} &:& \mbox{ ZZ} \,|\, \mbox{ QQ } \,|\,
                    575: \mbox{ integer32  } \,|\,
                    576: \mbox{ Polynomial in 1 variable } \\
                    577: & & \quad \,|\, \mbox{Tree} \,|\, \mbox{Zero} \,|\,\mbox{Dpolynomial}\\
                    578: \mbox{Name of the main variable } &:&
                    579: \mbox{ {\sl int32} v }   \\
                    580: & & \mbox{ --- v denotes a variable number. } \\
                    581: \mbox{Recursive Polynomial} &:&
                    582: \mbox{ ( {\tt CMO\_RECURSIVE\_POLYNOMIAL}, } \\
                    583: & & \quad \mbox{ RringDefinition, } \\
                    584: & & \quad
                    585: \mbox{ Polynomial in 1 variable}\, | \, \mbox{Coefficient}   \\
                    586: \mbox{RringDefinition}
                    587: & : &  \mbox{ {\sl List} v } \\
                    588: & & \quad \mbox{ --- v is a list of names of indeterminates. } \\
                    589: & & \quad \mbox{ --- It is sorted in the decreasing order. } \\
                    590: \end{eqnarray*}
                    591: */
1.1       noro      592: \bigbreak
                    593: \noindent
1.3       noro      594: Example:
1.1       noro      595: \begin{verbatim}
                    596: (CMO_RECURSIEVE_POLYNOMIAL, ("x","y"),
                    597: (CMO_POLYNOMIAL_IN_ONE_VARIABLE, 2,      0,  <--- "x"
                    598:   3, (CMO_POLYNOMIAL_IN_ONE_VARIABLE, 2, 1,  <--- "y"
                    599:        5, 1234,
                    600:        0, 17),
                    601:   1, (CMO_POLYNOMIAL_IN_ONE_VARIABLE, 2, 1,  <--- "y"
                    602:        10, 1,
                    603:        5, 31)))
                    604: \end{verbatim}
1.3       noro      605: //&jp これは,
                    606: //&eg This represents
                    607: $$   x^3 (1234 y^5 + 17 ) +  x^1 (y^{10} + 31 y^5)  $$
                    608: /*&jp
1.1       noro      609: をあらわす.
                    610: 非可換多項式もこの形式であらわしたいので, 積の順序を上のように
                    611: すること. つまり, 主変数かける係数の順番.
1.3       noro      612: */
                    613: /*&eg
                    614: We intend to represent non-commutative polynomials with the
                    615: same form. In such a case, the order of products are defined
1.4       noro      616: as above, that is a power of the main variable $\times$ a coeffcient.
1.3       noro      617: */
1.1       noro      618:
                    619: \noindent
                    620: \begin{verbatim}
                    621: sm1
                    622: sm1>(x^2-h). [(class) (recursivePolynomial)] dc /ff set ;
                    623: sm1>ff ::
                    624: Class.recursivePolynomial h * ((-1)) + (x^2  * (1))
                    625: \end{verbatim}
                    626:
1.3       noro      627: //&jp \subsection{CPU依存の double }
                    628: //&eg \subsection{CPU dependent double}
1.1       noro      629:
                    630: \begin{verbatim}
                    631: #define CMO_64BIT_MACHINE_DOUBLE   40
                    632: #define CMO_ARRAY_OF_64BIT_MACHINE_DOUBLE  41
                    633: #define CMO_128BIT_MACHINE_DOUBLE   42
                    634: #define CMO_ARRAY_OF_128BIT_MACHINE_DOUBLE  43
                    635: \end{verbatim}
                    636:
                    637: \noindent
1.4       noro      638: Group CMObject/MachineDouble requires CMObject/Primitive.\\
1.1       noro      639: 64bit machine double, Array of 64bit machine double
                    640: 128bit machine double, Array of 128bit machine double
                    641: $\in$ CMObject/MachineDouble \\
                    642:
1.3       noro      643: /*&jp
1.1       noro      644: \begin{eqnarray*}
                    645: \mbox{64bit machine double} &:&
                    646: \mbox{({\tt CMO\_64BIT\_MACHINE\_DOUBLE}, } \\
                    647: & & \quad \mbox{ {\sl byte} s1 , \ldots , {\sl byte}} s8)\\
                    648: & & \mbox{ --- s1, $\ldots$, s8 は {\tt double} (64bit). } \\
                    649: & & \mbox{ --- この表現はCPU依存である.}\\
                    650: &&  \mbox{\quad\quad mathcap に CPU 情報を付加しておく.} \\
                    651: \mbox{Array of 64bit machine double} &:&
                    652: \mbox{({\tt CMO\_ARRAY\_OF\_64BIT\_MACHINE\_DOUBLE}, {\sl int32} m, } \\
                    653: & & \quad \mbox{ {\sl byte} s1[1] , \ldots , {\sl byte}}\, s8[1], \ldots , {\sl byte}\, s8[m])\\
                    654: & & \mbox{ --- s*[1], $\ldots$ s*[m] は m 個の double (64bit) である. } \\
                    655: & & \mbox{ --- この表現はCPU依存である.}\\
                    656: & & \mbox{ \quad\quad mathcap に CPU 情報を付加しておく.} \\
                    657: \mbox{128bit machine double} &:&
                    658: \mbox{({\tt CMO\_128BIT\_MACHINE\_DOUBLE}, } \\
                    659: & & \quad \mbox{ {\sl byte} s1 , \ldots , {\sl byte}} s16)\\
                    660: & & \mbox{ --- s1, $\ldots$, s16 は {\tt long double} (128bit). } \\
                    661: & & \mbox{ --- この表現はCPU依存である.}\\
                    662: &&  \mbox{\quad\quad mathcap に CPU 情報を付加しておく.} \\
                    663: \mbox{Array of 128bit machine double} &:&
                    664: \mbox{({\tt CMO\_ARRAY\_OF\_128BIT\_MACHINE\_DOUBLE}, {\sl int32} m, } \\
                    665: & & \quad \mbox{ {\sl byte} s1[1] , \ldots , {\sl byte}} s16[1], \ldots , {\sl byte} s16[m])\\
                    666: & & \mbox{ --- s*[1], $\ldots$ s*[m] は m 個の long double (128bit) である. } \\
                    667: & & \mbox{ --- この表現はCPU依存である.}\\
                    668: & & \mbox{ \quad\quad mathcap に CPU 情報を付加しておく.}
                    669: \end{eqnarray*}
1.3       noro      670: */
                    671: /*&eg
                    672: \begin{eqnarray*}
                    673: \mbox{64bit machine double} &:&
                    674: \mbox{({\tt CMO\_64BIT\_MACHINE\_DOUBLE}, } \\
                    675: & & \quad \mbox{ {\sl byte} s1 , \ldots , {\sl byte}} s8)\\
                    676: & & \mbox{ --- s1, $\ldots$, s8 は {\tt double} (64bit). } \\
                    677: & & \mbox{ --- This depends on CPU.}\\
                    678: &&  \mbox{\quad\quad Add informations on CPU to the mathcap.} \\
                    679: \mbox{Array of 64bit machine double} &:&
                    680: \mbox{({\tt CMO\_ARRAY\_OF\_64BIT\_MACHINE\_DOUBLE}, {\sl int32} m, } \\
                    681: & & \quad \mbox{ {\sl byte} s1[1] , \ldots , {\sl byte}}\, s8[1], \ldots , {\sl byte}\, s8[m])\\
                    682: & & \mbox{ --- s*[1], $\ldots$ s*[m] are 64bit double's. } \\
                    683: & & \mbox{ --- This depends on CPU.}\\
                    684: & & \mbox{\quad\quad Add informations on CPU to the mathcap.} \\
                    685: \mbox{128bit machine double} &:&
                    686: \mbox{({\tt CMO\_128BIT\_MACHINE\_DOUBLE}, } \\
                    687: & & \quad \mbox{ {\sl byte} s1 , \ldots , {\sl byte}} s16)\\
                    688: & & \mbox{ --- s1, $\ldots$, s16 は {\tt long double} (128bit). } \\
                    689: & & \mbox{ --- This depends on CPU.}\\
                    690: & & \mbox{\quad\quad Add informations on CPU to the mathcap.} \\
                    691: \mbox{Array of 128bit machine double} &:&
                    692: \mbox{({\tt CMO\_ARRAY\_OF\_128BIT\_MACHINE\_DOUBLE}, {\sl int32} m, } \\
                    693: & & \quad \mbox{ {\sl byte} s1[1] , \ldots , {\sl byte}} s16[1], \ldots , {\sl byte} s16[m])\\
                    694: & & \mbox{ --- s*[1], $\ldots$ s*[m] are 128bit long double's. } \\
                    695: & & \mbox{ --- This depends on CPU.}\\
                    696: & & \mbox{\quad\quad Add informations on CPU to the mathcap.} \\
                    697: \end{eqnarray*}
                    698: */
1.1       noro      699:
                    700: \bigbreak
1.3       noro      701: //&jp 次に IEEE 準拠の float および Big float を定義しよう.
1.5       noro      702: //&eg We define float and big float conforming to the IEEE standard.
1.1       noro      703: \begin{verbatim}
                    704: #define CMO_BIGFLOAT   50
                    705: #define CMO_IEEE_DOUBLE_FLOAT 51
                    706: \end{verbatim}
                    707:
1.3       noro      708: /*&jp
                    709: IEEE 準拠の float については, IEEE 754 double precision floating-point
                    710: format (64 bit) の定義を見よ.
                    711: */
                    712: /*&eg
1.5       noro      713: See IEEE 754 double precision floating-point (64 bit) for the details of
                    714: float conforming to the IEEE standard.
1.3       noro      715: */
1.1       noro      716:
                    717: \noindent
1.4       noro      718: Group CMObject/Bigfloat requires CMObject/Primitive, CMObject/Basic.\\
1.1       noro      719: Bigfloat
                    720: $\in$ CMObject/Bigfloat \\
                    721:
                    722: \begin{eqnarray*}
                    723: \mbox{Bigfloat} &:&
                    724: \mbox{({\tt CMO\_BIGFLOAT}, } \\
                    725: & & \quad \mbox{ {\sl ZZ} a , {\sl ZZ} e})\\
1.3       noro      726: & & \mbox{ --- $a \times 2^e$. } \\
1.1       noro      727: \end{eqnarray*}

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>