[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.10

1.10    ! takayama    1: %% $OpenXM: OpenXM/doc/OpenXM-specs/cmo-basic1.tex,v 1.9 2000/09/12 23:09:18 noro 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}
1.10    ! takayama  226: //&jp  Leave の成分には, 多項式を含む任意のオブジェクトがきてよい.
        !           227: //&eg  Elements of the leave may be any objects including polynomials.
1.1       noro      228:
                    229: \noindent
                    230: Example:
                    231: \begin{verbatim}
                    232: sm1> [(plus) (Basic) [(123).. (345)..]] [(class) (tree)] dc ::
1.8       takayama  233: Class.tree [    $plus$ , $basic$ , [    123 , 345 ]  ]
1.1       noro      234: \end{verbatim}
                    235:
                    236:
                    237:
                    238: \bigbreak
1.3       noro      239: //&jp 次に, 分散表現多項式に関係するグループを定義しよう.
1.4       noro      240: /*&eg
                    241: Let us define a group for distributed polynomials. In the following
                    242: DMS stands for Distributed Monomial System.
                    243: */
1.1       noro      244:
                    245: \medbreak
                    246: \noindent
1.4       noro      247: Group CMObject/DistributedPolynomials requires CMObject/Primitive,
                    248: CMObject/Basic. \\
1.1       noro      249: Monomial, Monomial32, Coefficient, Dpolynomial, DringDefinition,
                    250: Generic DMS ring, RingByName, DMS of N variables $\in$
                    251: CMObject/DistributedPolynomials. \\
1.3       noro      252: /*&jp
1.1       noro      253: \begin{eqnarray*}
                    254: \mbox{Monomial} &:& \mbox{Monomial32}\, |\, \mbox{Zero} \\
                    255: \mbox{Monomial32}&:& ({\tt CMO\_MONOMIAL32}, {\sl int32}\, n,
                    256: {\sl int32}\, \mbox{e[1]}, \ldots,
                    257: {\sl int32}\, \mbox{e[n]}, \\
                    258: & & \ \mbox{Coefficient}) \\
                    259: & & \mbox{ --- e[i] で, $n$ 変数 monomial
                    260: $x^e = x_1^{e_1} \cdots x_n^{e_n}$ の各指数 $e_i$
                    261: をあらわす.} \\
                    262: \mbox{Coefficient}&:& \mbox{ZZ} | \mbox{Integer32} \\
                    263: \mbox{Dpolynomial}&:& \mbox{Zero} \\
                    264: & & |\ ({\tt CMO\_DISTRIBUTED\_POLYNOMIAL},{\sl int32} m, \\
                    265: & & \ \ \mbox{DringDefinition},
                    266: [\mbox{Monomial32}|\mbox{Zero}], \\
                    267: & &\ \
                    268: \{\mbox{Monomial32}\}) \\
                    269: & &\mbox{--- m はモノミアルの個数である.}\\
                    270: \mbox{DringDefinition}
                    271: &:& \mbox{DMS of N variables} \\
                    272: & & |\ \mbox{RingByName} \\
                    273: & & |\ \mbox{Generic DMS ring} \\
                    274: & & \mbox{ --- 分散表現多項式環の定義. } \\
                    275: \mbox{Generic DMS ring}
1.2       noro      276: &:& \mbox{({\tt CMO\_DMS\_GENERIC}) --- 新版はこちら}\\
1.1       noro      277: \mbox{RingByName}&:& ({\tt CMO\_RING\_BY\_NAME}, {\sl Cstring}\  {\rm s}) \\
                    278: & & \mbox{ --- 名前 s で, 格納された ring 定義.} \\
                    279: \mbox{DMS of N variables}
                    280: &:& ({\tt CMO\_DMS\_OF\_N\_VARIABLES}, \\
                    281: & & \ ({\tt CMO\_LIST}, {\sl int32}\, \mbox{m},
                    282: {\sl Integer32}\,  \mbox{n}, {\sl Integer32}\,\mbox{p} \\
                    283: & & \ \ [,{\sl object}\,\mbox{s}, {\sl Cstring}\,\mbox{c},
                    284:           {\sl List}\, \mbox{vlist},
                    285: {\sl List}\, \mbox{wvec}, {\sl List}\, \mbox{outord}]) \\
                    286: & & \mbox{ --- m はあとに続く要素の数} \\
                    287: & & \mbox{ --- n は変数の数, p は 標数} \\
                    288: & & \mbox{ --- s は ring の名前} \\
                    289: & & \mbox{ --- c は係数環, QQ, ZZ の場合は文字列で QQ, ZZ と書く.} \\
                    290: & & \mbox{ --- vlist は Indeterminate のリスト(新版). 多項式環の変数リスト} \\
                    291: & & \mbox{ --- wvec は order をきめる weight vector,} \\
                    292: & & \mbox{ --- outord は出力するときの変数順序.} \\
                    293: \end{eqnarray*}
1.3       noro      294: */
                    295: /*&eg
                    296: \begin{eqnarray*}
                    297: \mbox{Monomial} &:& \mbox{Monomial32}\, |\, \mbox{Zero} \\
                    298: \mbox{Monomial32}&:& ({\tt CMO\_MONOMIAL32}, {\sl int32}\, n,
                    299:                       {\sl int32}\, \mbox{e[1]}, \ldots,
                    300:                       {\sl int32}\, \mbox{e[n]}, \\
                    301:                  & & \ \mbox{Coefficient}) \\
                    302:                  & & \mbox{ --- e[i] is the exponent $e_i$ of the monomial
                    303:                       $x^e = x_1^{e_1} \cdots x_n^{e_n}$. } \\
                    304: \mbox{Coefficient}&:& \mbox{ZZ} | \mbox{Integer32} \\
                    305: \mbox{Dpolynomial}&:& \mbox{Zero} \\
                    306:                  & & |\ ({\tt CMO\_DISTRIBUTED\_POLYNOMIAL},{\sl int32} m, \\
                    307:                  & & \ \ \mbox{DringDefinition}, [\mbox{Monomial32}|\mbox{Zero}], \\
                    308:                  & &\ \
                    309:                     \{\mbox{Monomial32}\})  \\
                    310:                  & &\mbox{--- m is equal to the number of monomials.}\\
                    311: \mbox{DringDefinition}
                    312:                  &:& \mbox{DMS of N variables} \\
                    313:                  & & |\ \mbox{RingByName} \\
                    314:                  & & |\ \mbox{Generic DMS ring} \\
                    315:                  & & \mbox{ --- definition of the ring of distributed polynomials. } \\
                    316: \mbox{Generic DMS ring}
                    317:                  &:& ({\tt CMO\_DMS\_GENERIC}) \\
                    318: \mbox{RingByName}&:& ({\tt CMO\_RING\_BY\_NAME}, {\sl Cstring} s) \\
1.4       noro      319:                  & & \mbox{ --- The ring definition referred by the name ``s''.} \\
1.3       noro      320: \mbox{DMS of N variables}
                    321:                  &:& ({\tt CMO\_DMS\_OF\_N\_VARIABLES}, \\
                    322:                  & & \ ({\tt CMO\_LIST}, {\sl int32}\, \mbox{m},
                    323:                   {\sl Integer32}\,  \mbox{n}, {\sl Integer32}\, \mbox{p} \\
                    324:                  & & \ \ [,{\sl Cstring}\,\mbox{s}, {\sl List}\, \mbox{vlist},
                    325:                           {\sl List}\, \mbox{wvec}, {\sl List}\, \mbox{outord}]) \\
                    326:                  & & \mbox{ --- m is the number of elements.} \\
                    327:                  & & \mbox{ --- n is the number of variables, p is the characteristic} \\
                    328:                  & & \mbox{ --- s is the name of the ring, vlist is the list of variables.} \\
                    329:                  & & \mbox{ --- wvec is the weight vector.} \\
                    330:                  & & \mbox{ --- outord is the order of variables to output.} \\
                    331: \end{eqnarray*}
                    332: */
1.1       noro      333:
1.3       noro      334: /*&jp
1.1       noro      335: RingByName や DMS of N variables はなくても, DMS を定義できる.
                    336: したがって, これらを実装してないシステムで DMS を扱うものが
                    337: あってもかまわない.
                    338:
                    339: 以下, 以上の CMObject  にたいする,
                    340: xxx = asir, kan の振舞いを記述する.
1.3       noro      341: */
                    342: /*&eg
                    343: Note that it is possible to define DMS without RingByName and
                    344: DMS of N variables.
                    345:
                    346: In the following we describe how the above CMObjects
                    347: are implemented on Asir and Kan.
                    348: */
1.1       noro      349:
                    350: \subsection{ Zero}
1.3       noro      351: /*&jp
                    352: CMO では ゼロの表現法がなんとおりもあるが,
1.1       noro      353: どのようなゼロをうけとっても,
                    354: システムのゼロに変換できるべきである.
1.3       noro      355: */
                    356: /*&eg
                    357: Though CMO has various representations of zero,
                    358: each representation should be translated into zero
                    359: in the system.
                    360: */
1.1       noro      361:
                    362:
1.3       noro      363: //&jp \subsection{ 整数 ZZ }
                    364: //&eg \subsection{ Integer ZZ }
1.1       noro      365:
                    366: \begin{verbatim}
                    367: #define     CMO_ZZ          20
                    368: \end{verbatim}
                    369:
1.3       noro      370: /*&jp
                    371: この節ではOpen xxx 規約における任意の大きさの整数(bignum)の扱いについ
                    372: て説明する.  Open XM 規約における多重精度整数を表すデータ型 CMO\_ZZ は
                    373: GNU MPライブラリなどを参考にして設計されていて, 符号付き絶対値表現を用
                    374: いている.  (cf. {\tt kan/sm1} の配布ディレクトリのなかの {\tt
                    375: plugin/cmo-gmp.c}) CMO\_ZZ は次の形式をとる.
                    376: */
                    377: /*&eg
                    378: We describe the bignum (multi-precision integer) representation in OpenXM.
                    379: In OpenXM {\tt CMO\_ZZ} is used to represent bignum. Its design is similar
                    380: to that in GNU MP. (cf. {\tt plugin/cmo-gmp.c} in the {\tt kan/sm1}
                    381: distribution). CMO\_ZZ is defined as follows.
                    382: */
1.1       noro      383:
                    384: \begin{tabular}{|c|c|c|c|c|}
                    385: \hline
                    386: {\tt int32 CMO\_ZZ} & {\tt int32 $f$} & {\tt int32 $b_0$} & $\cdots$ &
                    387: {\tt int32 $b_{n}$} \\
                    388: \hline
1.3       noro      389: \end{tabular}
                    390:
                    391: /*&jp
                    392: $f$ は32bit整数である.  $b_0, \ldots, b_n$ は unsigned int32 である.
                    393: $|f|$ は $n+1$ である.  この CMO の符号は $f$ の符号で定める.  前述し
                    394: たように, 32bit整数の負数は 2 の補数表現で表される.
                    395:
                    396: Open xxx 規約では上の CMO は以下の整数を意味する. ($R = 2^{32}$)
                    397: */
                    398: /*&eg
                    399: $f$ is a 32bit integer. $b_0, \ldots, b_n$ are unsigned 32bit integers.
                    400: $|f|$ is equal to $n+1$.
                    401: The sign of $f$ represents that of the above CMO. As stated in Section
                    402: \ref{sec:basic0}, a negative 32bit integer is represented by
                    403: two's complement.
                    404:
                    405: In OpenXM the above CMO represents the following integer. ($R = 2^{32}$.)
                    406: */
1.1       noro      407:
                    408: \[
                    409: \mbox{sgn}(f)\times (b_0 R^{0}+ b_1 R^{1} + \cdots + b_{n-1}R^{n-1} + b_n R^n).
                    410: \]
1.3       noro      411:
                    412: /*&jp
                    413: {\tt int32} を network byte order で表現
                    414: しているとすると,例えば, 整数 $14$ は CMO\_ZZ で表わすと,
                    415: */
                    416: /*&eg
                    417: If we express {\tt int32} by the network byte order,
                    418: a CMO\_ZZ $14$ is expressed by
                    419: */
1.1       noro      420: \[
                    421: \mbox{(CMO\_ZZ, 1, 0, 0, 0, e)},
                    422: \]
1.3       noro      423: //&jp と表わす. これはバイト列では
1.4       noro      424: //&eg The corresponding byte sequence is
1.1       noro      425: \[
                    426: \mbox{\tt 00 00 00 14 00 00 00 01 00 00 00 0e}
                    427: \]
1.3       noro      428: //&jp となる.
1.1       noro      429:
                    430:
1.3       noro      431: //&jp なお ZZ の 0 ( (ZZ) 0 と書く ) は, {\tt (CMO\_ZZ, 00,00,00,00)} と表現する.
                    432: //&eg Note that CMO\_ZZ 0 is expressed by {\tt (CMO\_ZZ, 00,00,00,00)}.
1.1       noro      433:
                    434:
1.3       noro      435: //&jp \subsection{ 分散表現多項式 Dpolynomial }
                    436: //&eg \subsection{ Distributed polynomial Dpolynomial }
1.1       noro      437:
1.3       noro      438: /*&jp
1.1       noro      439: 環とそれに属する多項式は次のような考えかたであつかう.
                    440:
                    441: Generic DMS ring に属する元は,
                    442: 変数を $n$ 個持つ 適当な係数集合 $K$ を持つ多項式環 $K[x_1, \ldots, x_n]$
                    443: の元である.
                    444: 係数集合 $K$ がなにかは, 実際データを読み込み, Coefficient を見た段階で
                    445: わかる.
                    446: この環に属する多項式を CMO 形式でうけとった場合, 各サーバはその
                    447: サーバの対応する Object  に変換しないといけない.
                    448: この変換の仕方は, 各サーバ毎にきめる.
                    449:
                    450: Asir の場合は, $K[x_1, \ldots, x_n]$ の元は分散表現多項式に変換される.
                    451: \noroa{ でも, order はどうなるの? }
                    452:
                    453: {\tt kan/sm1} の場合は事情は複雑である.
                    454: {\tt kan/sm1} は, Generic DMS ring にあたる クラスをもたない.
                    455: つまり, Default で存在する, $n$ 変数の分散表現多項式環は存在しないわけである.
                    456: したがって, {\tt kan/sm1} では, DMS of N variables が来た場合,
                    457: これを CurrentRing の元として読み込む.  CurrentRing の変数の数が $n'$
                    458: で, $n' < n$ だと新しい多項式環を生成してデータを読み込む.
                    459: Order その他の optional 情報はすべて無視する.
                    460:
                    461: DMS の 2 番目のフィールドで,
                    462: Ring by Name を用いた場合, 現在の名前空間で変数 yyy に格納された ring object
                    463: の元として, この多項式を変換しなさいという意味になる.
                    464: {\tt kan/sm1} の場合, 環の定義は ring object として格納されており,
                    465: この ring object を 変数 yyy で参照することにより CMO としてうけとった
                    466: 多項式をこの ring の元として格納できる.
1.3       noro      467: */
1.1       noro      468:
1.3       noro      469: /*&eg
                    470: We treat polynomial rings and their elements as follows.
1.1       noro      471:
1.4       noro      472: Generic DMS ring is an $n$-variate polynomial ring $K[x_1, \ldots, x_n]$,
1.3       noro      473: where $K$ is some coefficient set. $K$ is unknown in advance
1.4       noro      474: and it is determined when coefficients of an element are received.
                    475: When a server has received an element in Generic DMS ring,
1.3       noro      476: the server has to translate it into the corresponding local object
                    477: on the server. Each server has its own translation scheme.
                    478: In Asir such an element are translated into a distributed polynomial.
                    479: In {\tt kan/sm1} things are complicated.
1.4       noro      480: {\tt kan/sm1} does not have any class corresponding to Generic DMS ring.
1.3       noro      481: {\tt kan/sm1} translates a DMS of N variables into an element of
                    482: the CurrentRing.
                    483: If the CurrentRing is $n'$-variate and $n' < n$, then
1.4       noro      484: an $n$-variate polynomial ring is newly created. Optional informations such as
1.3       noro      485: the term order are all ignored.
                    486:
1.4       noro      487: If RingByName ({\tt CMO\_RING\_BY\_NAME}, yyy)
1.3       noro      488: is specified as the second field of DMS,
                    489: it requests a sever to use a ring object whose name is yyy
                    490: as the destination ring for the translation.
                    491: This is done in {\tt kan/sm1}.
                    492: */
1.1       noro      493:
                    494: \medbreak \noindent
1.3       noro      495: //&jp {\bf Example}: (すべての数の表記は 16 進表記)
                    496: //&eg {\bf Example}: (all numbers are represented in hexadecimal notation)
1.1       noro      497: {\footnotesize \begin{verbatim}
                    498: Z/11Z [6 variables]
                    499: (kxx/cmotest.sm1) run
                    500: [(x,y) ring_of_polynomials ( ) elimination_order 11 ] define_ring ;
                    501: (3x^2 y). cmo /ff set ;
                    502: [(cmoLispLike) 1] extension ;
                    503: ff ::
                    504: Class.CMO CMO StandardEncoding: size = 52, size/sizeof(int) = 13,
                    505: tag=CMO_DISTRIBUTED_POLYNOMIAL
                    506:
                    507:   0  0  0 1f  0  0  0  1  0  0  0 18  0  0  0 13  0  0  0  6
                    508:   0  0  0  0  0  0  0  2  0  0  0  0  0  0  0  0  0  0  0  1
                    509:   0  0  0  0  0  0  0  2  0  0  0  3
                    510:
                    511: ff omc ::
                    512:  (CMO_DISTRIBUTED_POLYNOMIAL[1f],[size=]1,(CMO_DMS_GENERIC[18],),
                    513:   (CMO_MONOMIAL32[13],3*x^2*y),),
                    514: \end{verbatim} }
1.3       noro      515: /*&jp
                    516: $ 3 x^2 y$ は 6 変数の多項式環の 元としてみなされている.
                    517: */
                    518: /*&eg
                    519: $3 x^2 y$ is regarded as an element of a six-variate polynomial ring.
                    520: */
1.1       noro      521:
                    522:
1.3       noro      523: //&jp \subsection{再帰表現多項式の定義}
                    524: //&eg \subsection{Recursive polynomials}
1.1       noro      525:
                    526: \begin{verbatim}
                    527: #define CMO_RECURSIVE_POLYNOMIAL        27
                    528: #define CMO_POLYNOMIAL_IN_ONE_VARIABLE  33
                    529: \end{verbatim}
                    530:
1.4       noro      531: Group CMObject/RecursivePolynomial requires CMObject/Primitive, CMObject/Basic.\\
1.1       noro      532: Polynomial in 1 variable, Coefficient, Name of the main variable,
                    533: Recursive Polynomial, Ring definition for recursive polynomials
                    534: $\in$ CMObject/RecursivePolynomial \\
                    535:
1.3       noro      536: /*&jp
1.1       noro      537: \begin{eqnarray*}
                    538: \mbox{Polynomial in 1 variable} &:&
                    539: \mbox{({\tt CMO\_POLYNOMIAL\_IN\_ONE\_VARIABLE},\, {\sl int32}\, m, } \\
                    540: & & \quad \mbox{ Name of the main variable }, \\
                    541: & & \quad \mbox{ \{ {\sl int32} e, Coefficient \}} \\
                    542: & & \mbox{ --- m はモノミアルの個数. } \\
                    543: & & \mbox{ --- e, Coefficieint はモノミアルを表現している. } \\
                    544: & & \mbox{ --- 順序の高い順にならべる. 普通は巾の高い順.} \\
                    545: & & \mbox{ ---  e は 1変数多項式の巾をあらわす. } \\
                    546: \mbox{Coefficient} &:& \mbox{ ZZ} \,|\, \mbox{ QQ } \,|\,
                    547: \mbox{ integer32  } \,|\,
                    548: \mbox{ Polynomial in 1 variable } \\
                    549: & & \quad \,|\, \mbox{Tree} \,|\, \mbox{Zero} \,|\,\mbox{Dpolynomial}\\
                    550: \mbox{Name of the main variable } &:&
                    551: \mbox{ {\sl int32} v }   \\
                    552: & & \mbox{ --- v は 変数番号 (0 からはじまる) を表す. } \\
                    553: \mbox{Recursive Polynomial} &:&
                    554: \mbox{ ( {\tt CMO\_RECURSIVE\_POLYNOMIAL}, } \\
1.3       noro      555: & & \quad \mbox{ RringDefinition, } \\
1.1       noro      556: & & \quad
                    557: \mbox{ Polynomial in 1 variable}\, | \, \mbox{Coefficient}   \\
1.3       noro      558: \mbox{RringDefinition}
1.1       noro      559: & : &  \mbox{ {\sl List} v } \\
1.10    ! takayama  560: & & \quad \mbox{ --- v は, 変数名(indeterminate) または Tree のリスト. } \\
1.1       noro      561: & & \quad \mbox{ --- 順序の高い順. } \\
                    562: \end{eqnarray*}
1.3       noro      563: */
                    564: /*&eg
                    565: \begin{eqnarray*}
                    566: \mbox{Polynomial in 1 variable} &:&
                    567: \mbox{({\tt CMO\_POLYNOMIAL\_IN\_ONE\_VARIABLE},\, {\sl int32}\, m, } \\
                    568: & & \quad \mbox{ Name of the main variable }, \\
                    569: & & \quad \mbox{ \{ {\sl int32} e, Coefficient \}} \\
1.4       noro      570: & & \mbox{ --- m is the number of monomials. } \\
                    571: & & \mbox{ --- A pair of e and Coefficient represents a monomial. } \\
1.3       noro      572: & & \mbox{ --- The pairs of e and Coefficient are sorted in the } \\
                    573: & & \mbox{ \quad decreasing order, usually with respect to e.} \\
                    574: & & \mbox{ ---  e denotes an exponent of a monomial with respect to } \\
                    575: & & \mbox{ \quad the main variable. } \\
                    576: \mbox{Coefficient} &:& \mbox{ ZZ} \,|\, \mbox{ QQ } \,|\,
                    577: \mbox{ integer32  } \,|\,
                    578: \mbox{ Polynomial in 1 variable } \\
                    579: & & \quad \,|\, \mbox{Tree} \,|\, \mbox{Zero} \,|\,\mbox{Dpolynomial}\\
                    580: \mbox{Name of the main variable } &:&
                    581: \mbox{ {\sl int32} v }   \\
                    582: & & \mbox{ --- v denotes a variable number. } \\
                    583: \mbox{Recursive Polynomial} &:&
                    584: \mbox{ ( {\tt CMO\_RECURSIVE\_POLYNOMIAL}, } \\
                    585: & & \quad \mbox{ RringDefinition, } \\
                    586: & & \quad
                    587: \mbox{ Polynomial in 1 variable}\, | \, \mbox{Coefficient}   \\
                    588: \mbox{RringDefinition}
                    589: & : &  \mbox{ {\sl List} v } \\
1.10    ! takayama  590: & & \quad \mbox{ --- v is a list of names of indeterminates or trees. } \\
1.3       noro      591: & & \quad \mbox{ --- It is sorted in the decreasing order. } \\
                    592: \end{eqnarray*}
                    593: */
1.1       noro      594: \bigbreak
                    595: \noindent
1.3       noro      596: Example:
1.1       noro      597: \begin{verbatim}
                    598: (CMO_RECURSIEVE_POLYNOMIAL, ("x","y"),
                    599: (CMO_POLYNOMIAL_IN_ONE_VARIABLE, 2,      0,  <--- "x"
                    600:   3, (CMO_POLYNOMIAL_IN_ONE_VARIABLE, 2, 1,  <--- "y"
                    601:        5, 1234,
                    602:        0, 17),
                    603:   1, (CMO_POLYNOMIAL_IN_ONE_VARIABLE, 2, 1,  <--- "y"
                    604:        10, 1,
                    605:        5, 31)))
                    606: \end{verbatim}
1.3       noro      607: //&jp これは,
                    608: //&eg This represents
                    609: $$   x^3 (1234 y^5 + 17 ) +  x^1 (y^{10} + 31 y^5)  $$
                    610: /*&jp
1.1       noro      611: をあらわす.
                    612: 非可換多項式もこの形式であらわしたいので, 積の順序を上のように
                    613: すること. つまり, 主変数かける係数の順番.
1.3       noro      614: */
                    615: /*&eg
                    616: We intend to represent non-commutative polynomials with the
                    617: same form. In such a case, the order of products are defined
1.4       noro      618: as above, that is a power of the main variable $\times$ a coeffcient.
1.3       noro      619: */
1.1       noro      620:
                    621: \noindent
                    622: \begin{verbatim}
                    623: sm1
                    624: sm1>(x^2-h). [(class) (recursivePolynomial)] dc /ff set ;
                    625: sm1>ff ::
                    626: Class.recursivePolynomial h * ((-1)) + (x^2  * (1))
                    627: \end{verbatim}
                    628:
1.3       noro      629: //&jp \subsection{CPU依存の double }
                    630: //&eg \subsection{CPU dependent double}
1.1       noro      631:
                    632: \begin{verbatim}
                    633: #define CMO_64BIT_MACHINE_DOUBLE   40
                    634: #define CMO_ARRAY_OF_64BIT_MACHINE_DOUBLE  41
                    635: #define CMO_128BIT_MACHINE_DOUBLE   42
                    636: #define CMO_ARRAY_OF_128BIT_MACHINE_DOUBLE  43
                    637: \end{verbatim}
                    638:
                    639: \noindent
1.4       noro      640: Group CMObject/MachineDouble requires CMObject/Primitive.\\
1.1       noro      641: 64bit machine double, Array of 64bit machine double
                    642: 128bit machine double, Array of 128bit machine double
                    643: $\in$ CMObject/MachineDouble \\
                    644:
1.3       noro      645: /*&jp
1.1       noro      646: \begin{eqnarray*}
                    647: \mbox{64bit machine double} &:&
                    648: \mbox{({\tt CMO\_64BIT\_MACHINE\_DOUBLE}, } \\
                    649: & & \quad \mbox{ {\sl byte} s1 , \ldots , {\sl byte}} s8)\\
                    650: & & \mbox{ --- s1, $\ldots$, s8 は {\tt double} (64bit). } \\
                    651: & & \mbox{ --- この表現はCPU依存である.}\\
                    652: &&  \mbox{\quad\quad mathcap に CPU 情報を付加しておく.} \\
                    653: \mbox{Array of 64bit machine double} &:&
                    654: \mbox{({\tt CMO\_ARRAY\_OF\_64BIT\_MACHINE\_DOUBLE}, {\sl int32} m, } \\
                    655: & & \quad \mbox{ {\sl byte} s1[1] , \ldots , {\sl byte}}\, s8[1], \ldots , {\sl byte}\, s8[m])\\
                    656: & & \mbox{ --- s*[1], $\ldots$ s*[m] は m 個の double (64bit) である. } \\
                    657: & & \mbox{ --- この表現はCPU依存である.}\\
                    658: & & \mbox{ \quad\quad mathcap に CPU 情報を付加しておく.} \\
                    659: \mbox{128bit machine double} &:&
                    660: \mbox{({\tt CMO\_128BIT\_MACHINE\_DOUBLE}, } \\
                    661: & & \quad \mbox{ {\sl byte} s1 , \ldots , {\sl byte}} s16)\\
                    662: & & \mbox{ --- s1, $\ldots$, s16 は {\tt long double} (128bit). } \\
                    663: & & \mbox{ --- この表現はCPU依存である.}\\
                    664: &&  \mbox{\quad\quad mathcap に CPU 情報を付加しておく.} \\
                    665: \mbox{Array of 128bit machine double} &:&
                    666: \mbox{({\tt CMO\_ARRAY\_OF\_128BIT\_MACHINE\_DOUBLE}, {\sl int32} m, } \\
                    667: & & \quad \mbox{ {\sl byte} s1[1] , \ldots , {\sl byte}} s16[1], \ldots , {\sl byte} s16[m])\\
                    668: & & \mbox{ --- s*[1], $\ldots$ s*[m] は m 個の long double (128bit) である. } \\
                    669: & & \mbox{ --- この表現はCPU依存である.}\\
                    670: & & \mbox{ \quad\quad mathcap に CPU 情報を付加しておく.}
                    671: \end{eqnarray*}
1.3       noro      672: */
                    673: /*&eg
                    674: \begin{eqnarray*}
                    675: \mbox{64bit machine double} &:&
                    676: \mbox{({\tt CMO\_64BIT\_MACHINE\_DOUBLE}, } \\
                    677: & & \quad \mbox{ {\sl byte} s1 , \ldots , {\sl byte}} s8)\\
                    678: & & \mbox{ --- s1, $\ldots$, s8 は {\tt double} (64bit). } \\
                    679: & & \mbox{ --- This depends on CPU.}\\
                    680: &&  \mbox{\quad\quad Add informations on CPU to the mathcap.} \\
                    681: \mbox{Array of 64bit machine double} &:&
                    682: \mbox{({\tt CMO\_ARRAY\_OF\_64BIT\_MACHINE\_DOUBLE}, {\sl int32} m, } \\
                    683: & & \quad \mbox{ {\sl byte} s1[1] , \ldots , {\sl byte}}\, s8[1], \ldots , {\sl byte}\, s8[m])\\
                    684: & & \mbox{ --- s*[1], $\ldots$ s*[m] are 64bit double's. } \\
                    685: & & \mbox{ --- This depends on CPU.}\\
                    686: & & \mbox{\quad\quad Add informations on CPU to the mathcap.} \\
                    687: \mbox{128bit machine double} &:&
                    688: \mbox{({\tt CMO\_128BIT\_MACHINE\_DOUBLE}, } \\
                    689: & & \quad \mbox{ {\sl byte} s1 , \ldots , {\sl byte}} s16)\\
                    690: & & \mbox{ --- s1, $\ldots$, s16 は {\tt long double} (128bit). } \\
                    691: & & \mbox{ --- This depends on CPU.}\\
                    692: & & \mbox{\quad\quad Add informations on CPU to the mathcap.} \\
                    693: \mbox{Array of 128bit machine double} &:&
                    694: \mbox{({\tt CMO\_ARRAY\_OF\_128BIT\_MACHINE\_DOUBLE}, {\sl int32} m, } \\
                    695: & & \quad \mbox{ {\sl byte} s1[1] , \ldots , {\sl byte}} s16[1], \ldots , {\sl byte} s16[m])\\
                    696: & & \mbox{ --- s*[1], $\ldots$ s*[m] are 128bit long double's. } \\
                    697: & & \mbox{ --- This depends on CPU.}\\
                    698: & & \mbox{\quad\quad Add informations on CPU to the mathcap.} \\
                    699: \end{eqnarray*}
                    700: */
1.1       noro      701:
                    702: \bigbreak
1.3       noro      703: //&jp 次に IEEE 準拠の float および Big float を定義しよう.
1.5       noro      704: //&eg We define float and big float conforming to the IEEE standard.
1.1       noro      705: \begin{verbatim}
                    706: #define CMO_BIGFLOAT   50
                    707: #define CMO_IEEE_DOUBLE_FLOAT 51
                    708: \end{verbatim}
                    709:
1.3       noro      710: /*&jp
                    711: IEEE 準拠の float については, IEEE 754 double precision floating-point
                    712: format (64 bit) の定義を見よ.
                    713: */
                    714: /*&eg
1.5       noro      715: See IEEE 754 double precision floating-point (64 bit) for the details of
                    716: float conforming to the IEEE standard.
1.3       noro      717: */
1.1       noro      718:
                    719: \noindent
1.4       noro      720: Group CMObject/Bigfloat requires CMObject/Primitive, CMObject/Basic.\\
1.1       noro      721: Bigfloat
                    722: $\in$ CMObject/Bigfloat \\
                    723:
                    724: \begin{eqnarray*}
                    725: \mbox{Bigfloat} &:&
                    726: \mbox{({\tt CMO\_BIGFLOAT}, } \\
                    727: & & \quad \mbox{ {\sl ZZ} a , {\sl ZZ} e})\\
1.3       noro      728: & & \mbox{ --- $a \times 2^e$. } \\
1.1       noro      729: \end{eqnarray*}

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