Annotation of OpenXM/doc/OpenXM-specs/cmo-basic1.tex, Revision 1.4
1.4 ! noro 1: %% $OpenXM: OpenXM/doc/OpenXM-specs/cmo-basic1.tex,v 1.3 2000/01/23 05:28:33 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: \noroa{ tagged list を導入すべきか? cf. SSkan/plugin/cmo.txt }
31:
32: */
33: /*&eg
34: In the sequel, we will explain on the groups
1.4 ! noro 35: CMObject/Basic, CMObject/Tree
1.1 noro 36: and CMObject/DistributedPolynomial.
37: */
38:
39: /*&jp
40:
41: \bigbreak
42: \noindent
1.4 ! noro 43: Group CMObject/Basic requires CMObject/Primitive. \\
! 44: ZZ, QQ, Zero, Rational, Indeterminate,$\in$ CMObject/Basic. \\
1.1 noro 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
1.4 ! noro 63: Group CMObject/Basic requires CMObject/Primitive. \\
! 64: ZZ, QQ, Zero, Rational, Indeterminate,$\in$ CMObject/Basic. \\
1.1 noro 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
1.4 ! noro 105: Group CMObject/Tree requires CMObject/Basic. \\
! 106: Tree, Lambda $\in$ CMObject/Basic. \\
1.1 noro 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
1.4 ! noro 122: Group CMObject/Tree requires CMObject/Basic. \\
! 123: Tree, Lambda $\in$ CMObject/Basic. \\
1.1 noro 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.4 ! noro 163: Tree may be expressed by putting the expression between
1.3 noro 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 次に, 分散表現多項式に関係するグループを定義しよう.
1.4 ! noro 216: /*&eg
! 217: Let us define a group for distributed polynomials. In the following
! 218: DMS stands for Distributed Monomial System.
! 219: */
1.1 noro 220:
221: \medbreak
222: \noindent
1.4 ! noro 223: Group CMObject/DistributedPolynomials requires CMObject/Primitive,
! 224: CMObject/Basic. \\
1.1 noro 225: Monomial, Monomial32, Coefficient, Dpolynomial, DringDefinition,
226: Generic DMS ring, RingByName, DMS of N variables $\in$
227: CMObject/DistributedPolynomials. \\
1.3 noro 228: /*&jp
1.1 noro 229: \begin{eqnarray*}
230: \mbox{Monomial} &:& \mbox{Monomial32}\, |\, \mbox{Zero} \\
231: \mbox{Monomial32}&:& ({\tt CMO\_MONOMIAL32}, {\sl int32}\, n,
232: {\sl int32}\, \mbox{e[1]}, \ldots,
233: {\sl int32}\, \mbox{e[n]}, \\
234: & & \ \mbox{Coefficient}) \\
235: & & \mbox{ --- e[i] で, $n$ 変数 monomial
236: $x^e = x_1^{e_1} \cdots x_n^{e_n}$ の各指数 $e_i$
237: をあらわす.} \\
238: \mbox{Coefficient}&:& \mbox{ZZ} | \mbox{Integer32} \\
239: \mbox{Dpolynomial}&:& \mbox{Zero} \\
240: & & |\ ({\tt CMO\_DISTRIBUTED\_POLYNOMIAL},{\sl int32} m, \\
241: & & \ \ \mbox{DringDefinition},
242: [\mbox{Monomial32}|\mbox{Zero}], \\
243: & &\ \
244: \{\mbox{Monomial32}\}) \\
245: & &\mbox{--- m はモノミアルの個数である.}\\
246: \mbox{DringDefinition}
247: &:& \mbox{DMS of N variables} \\
248: & & |\ \mbox{RingByName} \\
249: & & |\ \mbox{Generic DMS ring} \\
250: & & \mbox{ --- 分散表現多項式環の定義. } \\
251: \mbox{Generic DMS ring}
1.2 noro 252: &:& \mbox{({\tt CMO\_DMS\_GENERIC}) --- 新版はこちら}\\
1.1 noro 253: \mbox{RingByName}&:& ({\tt CMO\_RING\_BY\_NAME}, {\sl Cstring}\ {\rm s}) \\
254: & & \mbox{ --- 名前 s で, 格納された ring 定義.} \\
255: \mbox{DMS of N variables}
256: &:& ({\tt CMO\_DMS\_OF\_N\_VARIABLES}, \\
257: & & \ ({\tt CMO\_LIST}, {\sl int32}\, \mbox{m},
258: {\sl Integer32}\, \mbox{n}, {\sl Integer32}\,\mbox{p} \\
259: & & \ \ [,{\sl object}\,\mbox{s}, {\sl Cstring}\,\mbox{c},
260: {\sl List}\, \mbox{vlist},
261: {\sl List}\, \mbox{wvec}, {\sl List}\, \mbox{outord}]) \\
262: & & \mbox{ --- m はあとに続く要素の数} \\
263: & & \mbox{ --- n は変数の数, p は 標数} \\
264: & & \mbox{ --- s は ring の名前} \\
265: & & \mbox{ --- c は係数環, QQ, ZZ の場合は文字列で QQ, ZZ と書く.} \\
266: & & \mbox{ --- vlist は Indeterminate のリスト(新版). 多項式環の変数リスト} \\
267: & & \mbox{ --- wvec は order をきめる weight vector,} \\
268: & & \mbox{ --- outord は出力するときの変数順序.} \\
269: \end{eqnarray*}
1.3 noro 270: */
271: /*&eg
272: \begin{eqnarray*}
273: \mbox{Monomial} &:& \mbox{Monomial32}\, |\, \mbox{Zero} \\
274: \mbox{Monomial32}&:& ({\tt CMO\_MONOMIAL32}, {\sl int32}\, n,
275: {\sl int32}\, \mbox{e[1]}, \ldots,
276: {\sl int32}\, \mbox{e[n]}, \\
277: & & \ \mbox{Coefficient}) \\
278: & & \mbox{ --- e[i] is the exponent $e_i$ of the monomial
279: $x^e = x_1^{e_1} \cdots x_n^{e_n}$. } \\
280: \mbox{Coefficient}&:& \mbox{ZZ} | \mbox{Integer32} \\
281: \mbox{Dpolynomial}&:& \mbox{Zero} \\
282: & & |\ ({\tt CMO\_DISTRIBUTED\_POLYNOMIAL},{\sl int32} m, \\
283: & & \ \ \mbox{DringDefinition}, [\mbox{Monomial32}|\mbox{Zero}], \\
284: & &\ \
285: \{\mbox{Monomial32}\}) \\
286: & &\mbox{--- m is equal to the number of monomials.}\\
287: \mbox{DringDefinition}
288: &:& \mbox{DMS of N variables} \\
289: & & |\ \mbox{RingByName} \\
290: & & |\ \mbox{Generic DMS ring} \\
291: & & \mbox{ --- definition of the ring of distributed polynomials. } \\
292: \mbox{Generic DMS ring}
293: &:& ({\tt CMO\_DMS\_GENERIC}) \\
294: \mbox{RingByName}&:& ({\tt CMO\_RING\_BY\_NAME}, {\sl Cstring} s) \\
1.4 ! noro 295: & & \mbox{ --- The ring definition referred by the name ``s''.} \\
1.3 noro 296: \mbox{DMS of N variables}
297: &:& ({\tt CMO\_DMS\_OF\_N\_VARIABLES}, \\
298: & & \ ({\tt CMO\_LIST}, {\sl int32}\, \mbox{m},
299: {\sl Integer32}\, \mbox{n}, {\sl Integer32}\, \mbox{p} \\
300: & & \ \ [,{\sl Cstring}\,\mbox{s}, {\sl List}\, \mbox{vlist},
301: {\sl List}\, \mbox{wvec}, {\sl List}\, \mbox{outord}]) \\
302: & & \mbox{ --- m is the number of elements.} \\
303: & & \mbox{ --- n is the number of variables, p is the characteristic} \\
304: & & \mbox{ --- s is the name of the ring, vlist is the list of variables.} \\
305: & & \mbox{ --- wvec is the weight vector.} \\
306: & & \mbox{ --- outord is the order of variables to output.} \\
307: \end{eqnarray*}
308: */
1.1 noro 309:
1.3 noro 310: /*&jp
1.1 noro 311: RingByName や DMS of N variables はなくても, DMS を定義できる.
312: したがって, これらを実装してないシステムで DMS を扱うものが
313: あってもかまわない.
314:
315: 以下, 以上の CMObject にたいする,
316: xxx = asir, kan の振舞いを記述する.
1.3 noro 317: */
318: /*&eg
319: Note that it is possible to define DMS without RingByName and
320: DMS of N variables.
321:
322: In the following we describe how the above CMObjects
323: are implemented on Asir and Kan.
324: */
1.1 noro 325:
326: \subsection{ Zero}
1.3 noro 327: /*&jp
328: CMO では ゼロの表現法がなんとおりもあるが,
1.1 noro 329: どのようなゼロをうけとっても,
330: システムのゼロに変換できるべきである.
1.3 noro 331: */
332: /*&eg
333: Though CMO has various representations of zero,
334: each representation should be translated into zero
335: in the system.
336: */
1.1 noro 337:
338:
1.3 noro 339: //&jp \subsection{ 整数 ZZ }
340: //&eg \subsection{ Integer ZZ }
1.1 noro 341:
342: \begin{verbatim}
343: #define CMO_ZZ 20
344: \end{verbatim}
345:
1.3 noro 346: /*&jp
347: この節ではOpen xxx 規約における任意の大きさの整数(bignum)の扱いについ
348: て説明する. Open XM 規約における多重精度整数を表すデータ型 CMO\_ZZ は
349: GNU MPライブラリなどを参考にして設計されていて, 符号付き絶対値表現を用
350: いている. (cf. {\tt kan/sm1} の配布ディレクトリのなかの {\tt
351: plugin/cmo-gmp.c}) CMO\_ZZ は次の形式をとる.
352: */
353: /*&eg
354: We describe the bignum (multi-precision integer) representation in OpenXM.
355: In OpenXM {\tt CMO\_ZZ} is used to represent bignum. Its design is similar
356: to that in GNU MP. (cf. {\tt plugin/cmo-gmp.c} in the {\tt kan/sm1}
357: distribution). CMO\_ZZ is defined as follows.
358: */
1.1 noro 359:
360: \begin{tabular}{|c|c|c|c|c|}
361: \hline
362: {\tt int32 CMO\_ZZ} & {\tt int32 $f$} & {\tt int32 $b_0$} & $\cdots$ &
363: {\tt int32 $b_{n}$} \\
364: \hline
1.3 noro 365: \end{tabular}
366:
367: /*&jp
368: $f$ は32bit整数である. $b_0, \ldots, b_n$ は unsigned int32 である.
369: $|f|$ は $n+1$ である. この CMO の符号は $f$ の符号で定める. 前述し
370: たように, 32bit整数の負数は 2 の補数表現で表される.
371:
372: Open xxx 規約では上の CMO は以下の整数を意味する. ($R = 2^{32}$)
373: */
374: /*&eg
375: $f$ is a 32bit integer. $b_0, \ldots, b_n$ are unsigned 32bit integers.
376: $|f|$ is equal to $n+1$.
377: The sign of $f$ represents that of the above CMO. As stated in Section
378: \ref{sec:basic0}, a negative 32bit integer is represented by
379: two's complement.
380:
381: In OpenXM the above CMO represents the following integer. ($R = 2^{32}$.)
382: */
1.1 noro 383:
384: \[
385: \mbox{sgn}(f)\times (b_0 R^{0}+ b_1 R^{1} + \cdots + b_{n-1}R^{n-1} + b_n R^n).
386: \]
1.3 noro 387:
388: /*&jp
389: {\tt int32} を network byte order で表現
390: しているとすると,例えば, 整数 $14$ は CMO\_ZZ で表わすと,
391: */
392: /*&eg
393: If we express {\tt int32} by the network byte order,
394: a CMO\_ZZ $14$ is expressed by
395: */
1.1 noro 396: \[
397: \mbox{(CMO\_ZZ, 1, 0, 0, 0, e)},
398: \]
1.3 noro 399: //&jp と表わす. これはバイト列では
1.4 ! noro 400: //&eg The corresponding byte sequence is
1.1 noro 401: \[
402: \mbox{\tt 00 00 00 14 00 00 00 01 00 00 00 0e}
403: \]
1.3 noro 404: //&jp となる.
1.1 noro 405:
406:
1.3 noro 407: //&jp なお ZZ の 0 ( (ZZ) 0 と書く ) は, {\tt (CMO\_ZZ, 00,00,00,00)} と表現する.
408: //&eg Note that CMO\_ZZ 0 is expressed by {\tt (CMO\_ZZ, 00,00,00,00)}.
1.1 noro 409:
410:
1.3 noro 411: //&jp \subsection{ 分散表現多項式 Dpolynomial }
412: //&eg \subsection{ Distributed polynomial Dpolynomial }
1.1 noro 413:
1.3 noro 414: /*&jp
1.1 noro 415: 環とそれに属する多項式は次のような考えかたであつかう.
416:
417: Generic DMS ring に属する元は,
418: 変数を $n$ 個持つ 適当な係数集合 $K$ を持つ多項式環 $K[x_1, \ldots, x_n]$
419: の元である.
420: 係数集合 $K$ がなにかは, 実際データを読み込み, Coefficient を見た段階で
421: わかる.
422: この環に属する多項式を CMO 形式でうけとった場合, 各サーバはその
423: サーバの対応する Object に変換しないといけない.
424: この変換の仕方は, 各サーバ毎にきめる.
425:
426: Asir の場合は, $K[x_1, \ldots, x_n]$ の元は分散表現多項式に変換される.
427: \noroa{ でも, order はどうなるの? }
428:
429: {\tt kan/sm1} の場合は事情は複雑である.
430: {\tt kan/sm1} は, Generic DMS ring にあたる クラスをもたない.
431: つまり, Default で存在する, $n$ 変数の分散表現多項式環は存在しないわけである.
432: したがって, {\tt kan/sm1} では, DMS of N variables が来た場合,
433: これを CurrentRing の元として読み込む. CurrentRing の変数の数が $n'$
434: で, $n' < n$ だと新しい多項式環を生成してデータを読み込む.
435: Order その他の optional 情報はすべて無視する.
436:
437: DMS の 2 番目のフィールドで,
438: Ring by Name を用いた場合, 現在の名前空間で変数 yyy に格納された ring object
439: の元として, この多項式を変換しなさいという意味になる.
440: {\tt kan/sm1} の場合, 環の定義は ring object として格納されており,
441: この ring object を 変数 yyy で参照することにより CMO としてうけとった
442: 多項式をこの ring の元として格納できる.
1.3 noro 443: */
1.1 noro 444:
1.3 noro 445: /*&eg
446: We treat polynomial rings and their elements as follows.
1.1 noro 447:
1.4 ! noro 448: Generic DMS ring is an $n$-variate polynomial ring $K[x_1, \ldots, x_n]$,
1.3 noro 449: where $K$ is some coefficient set. $K$ is unknown in advance
1.4 ! noro 450: and it is determined when coefficients of an element are received.
! 451: When a server has received an element in Generic DMS ring,
1.3 noro 452: the server has to translate it into the corresponding local object
453: on the server. Each server has its own translation scheme.
454: In Asir such an element are translated into a distributed polynomial.
455: In {\tt kan/sm1} things are complicated.
1.4 ! noro 456: {\tt kan/sm1} does not have any class corresponding to Generic DMS ring.
1.3 noro 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
1.4 ! noro 460: an $n$-variate polynomial ring is newly created. Optional informations such as
1.3 noro 461: the term order are all ignored.
462:
1.4 ! noro 463: If RingByName ({\tt CMO\_RING\_BY\_NAME}, yyy)
1.3 noro 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:
1.4 ! noro 507: Group CMObject/RecursivePolynomial requires CMObject/Primitive, CMObject/Basic.\\
1.1 noro 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 \}} \\
1.4 ! noro 546: & & \mbox{ --- m is the number of monomials. } \\
! 547: & & \mbox{ --- A pair of e and Coefficient represents a monomial. } \\
1.3 noro 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
1.4 ! noro 594: as above, that is a power of the main variable $\times$ a coeffcient.
1.3 noro 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
1.4 ! noro 616: Group CMObject/MachineDouble requires CMObject/Primitive.\\
1.1 noro 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
1.4 ! noro 696: Group CMObject/Bigfloat requires CMObject/Primitive, CMObject/Basic.\\
1.1 noro 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>