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

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

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