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

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

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