=================================================================== RCS file: /home/cvs/OpenXM/doc/OpenXM-specs/cmo-basic1.tex,v retrieving revision 1.2 retrieving revision 1.15 diff -u -p -r1.2 -r1.15 --- OpenXM/doc/OpenXM-specs/cmo-basic1.tex 2000/01/23 00:41:08 1.2 +++ OpenXM/doc/OpenXM-specs/cmo-basic1.tex 2016/08/22 05:38:27 1.15 @@ -1,7 +1,7 @@ -%% $OpenXM: OpenXM/doc/OpenXM-specs/cmo-basic1.tex,v 1.1.1.1 2000/01/20 08:52:46 noro Exp $ +%% $OpenXM: OpenXM/doc/OpenXM-specs/cmo-basic1.tex,v 1.14 2015/08/18 02:54:05 noro Exp $ //&jp \section{ 数, 多項式 の CMO 表現 } //&eg \section{ CMOexpressions for numbers and polynomials } - +\label{sec:basic1} /*&C @../SSkan/plugin/cmotag.h \begin{verbatim} @@ -14,7 +14,9 @@ #define CMO_RING_BY_NAME 26 #define CMO_DISTRIBUTED_POLYNOMIAL 31 #define CMO_RATIONAL 34 +#define CMO_COMPLEX 35 +#define CMO_BIGFLOAT32 52 #define CMO_INDETERMINATE 60 #define CMO_TREE 61 @@ -24,54 +26,90 @@ */ /*&jp -以下, グループ CMObject/Basic1, CMObject/Tree +以下, グループ CMObject/Basic, CMObject/Tree および CMObject/DistributedPolynomial に属する CMObject の形式を説明する. -\noroa{ tagged list を導入すべきか? cf. SSkan/plugin/cmo.txt } +\noindent +{\tt OpenXM/src/ox\_toolkit} にある {\tt bconv} をもちいると +CMO expression を binary format に変換できるので, +これを参考にするといい. */ /*&eg In the sequel, we will explain on the groups -CMObject/Basic1, CMObject/Tree +CMObject/Basic, CMObject/Tree and CMObject/DistributedPolynomial. + +\noindent +The program {\tt bconv} at {\tt OpenXM/src/ox\_toolkit} +translates +CMO expressions into binary formats. +It is convinient to understand the binary formats explained in +this section. */ +/*&C +\noindent Example: +\begin{verbatim} +bash$ ./bconv +> (CMO_ZZ,123123); +00 00 00 14 00 00 00 01 00 01 e0 f3 +\end{verbatim} +*/ /*&jp \bigbreak \noindent -Group CMObject/Basic1 requires CMObject/Basic0. \\ -ZZ, QQ, Zero, Rational, Indeterminate,$\in$ CMObject/Basic1. \\ +Group CMObject/Basic requires CMObject/Primitive. \\ +ZZ, QQ, Zero, Rational, Indeterminate $\in$ CMObject/Basic. \\ \begin{eqnarray*} \mbox{Zero} &:& ({\tt CMO\_ZERO}) \\ & & \mbox{ --- ユニバーサルな ゼロを表す. } \\ -\mbox{ZZ} &:& ({\tt CMO\_ZZ},{\sl int32}\, {\rm f}, {\sl byte}\, \mbox{a[1]}, \ldots -{\sl byte}\, \mbox{a[m]} ) \\ +\mbox{ZZ} &:& ({\tt CMO\_ZZ},{\sl int32}\, {\rm f}, {\sl byte}\, \mbox{a[1]}, \ldots , +{\sl byte}\, \mbox{a[$|$f$|$]} ) \\ &:& \mbox{ --- bignum をあらわす. a[i] についてはあとで説明}\\ -\mbox{QQ} &:& ({\tt CMO\_QQ}, {\sl ZZ}\, {\rm a}, {\sl ZZ}\, {\rm b}) \\ +\mbox{QQ} &:& ({\tt CMO\_QQ}, + {\sl int32}\, {\rm m}, {\sl byte}\, \mbox{a[1]}, \ldots, {\sl byte}\, \mbox{a[$|$m$|$]}, + {\sl int32}\, {\rm n}, {\sl byte}\, \mbox{b[1]}, \ldots, {\sl byte}\, \mbox{b[$|$n$|$]})\\ & & \mbox{ --- 有理数 $a/b$ を表す. } \\ \mbox{Rational} &:& ({\tt CMO\_RATIONAL}, {\sl CMObject}\, {\rm a}, {\sl CMObject}\, {\rm b}) \\ & & \mbox{ --- $a/b$ を表す. } \\ +\mbox{Bigfloat32} &:& ({\tt CMO\_BIGFLOAT32}, +{\sl int32}\, {\rm prec}, {\sl int32}\, {\rm sign}, {\sl int32}\, {\rm exp}, +{\sl int32}\, \mbox{a[1]}, \ldots , {\sl int32}\, \mbox{a[k]} ) \\ +&:& \mbox{ --- bigfloat をあらわす. a[i], k についてはあとで説明}\\ +\mbox{Complex} &:& ({\tt CMO\_COMPLEX}, {\sl CMObject}\, {\rm re}, {\sl CMObject}\, {\rm im}) \\ +& & \mbox{ --- $a+b\sqrt{-1}$ を表す. } \\ \mbox{Indeterminate} &:& ({\tt CMO\_INDETERMINATE}, {\sl Cstring}\, {\rm v}) \\ & & \mbox{ --- 変数名 $v$ . } \\ \end{eqnarray*} */ + + /*&eg \bigbreak \noindent -Group CMObject/Basic1 requires CMObject/Basic0. \\ -ZZ, QQ, Zero, Rational, Indeterminate,$\in$ CMObject/Basic1. \\ +Group CMObject/Basic requires CMObject/Primitive. \\ +ZZ, QQ, Zero, Rational, Indeterminate $\in$ CMObject/Basic. \\ \begin{eqnarray*} \mbox{Zero} &:& ({\tt CMO\_ZERO}) \\ & & \mbox{ --- Universal zero } \\ -\mbox{ZZ} &:& ({\tt CMO\_ZZ},{\sl int32}\, {\rm f}, {\sl byte}\, \mbox{a[1]}, \ldots -{\sl byte}\, \mbox{a[m]} ) \\ +\mbox{ZZ} &:& ({\tt CMO\_ZZ},{\sl int32}\, {\rm f}, {\sl byte}\, \mbox{a[1]}, \ldots , +{\sl byte}\, \mbox{a[$|$m$|$]} ) \\ &:& \mbox{ --- bignum. The meaning of a[i] will be explained later.}\\ -\mbox{QQ} &:& ({\tt CMO\_QQ}, {\sl ZZ}\, {\rm a}, {\sl ZZ}\, {\rm b}) \\ +\mbox{QQ} &:& ({\tt CMO\_QQ}, + {\sl int32}\, {\rm m}, {\sl byte}\, \mbox{a[1]}, \ldots, {\sl byte}\, \mbox{a[$|$m$|$]}, + {\sl int32}\, {\rm n}, {\sl byte}\, \mbox{b[1]}, \ldots, {\sl byte}\, \mbox{b[$|$n$|$]})\\ & & \mbox{ --- Rational number $a/b$. } \\ \mbox{Rational} &:& ({\tt CMO\_RATIONAL}, {\sl CMObject}\, {\rm a}, {\sl CMObject}\, {\rm b}) \\ & & \mbox{ --- Rational expression $a/b$. } \\ +\mbox{Bigfloat32} &:& ({\tt CMO\_BIGFLOAT32}, +{\sl int32}\, {\rm prec}, {\sl int32}\, {\rm sign}, {\sl int32}\, {\rm exp}, +{\sl int32}\, \mbox{a[1]}, \ldots , {\sl int32}\, \mbox{a[k]} ) \\ +&:& \mbox{ --- bigfloat. The meaning of a[i], k will be explained later.}\\ +\mbox{Complex} &:& ({\tt CMO\_COMPLEX}, {\sl CMObject}\, {\rm re}, {\sl CMObject}\, {\rm im}) \\ +& & \mbox{ --- Complex number $a+b\sqrt{-1}$. } \\ \mbox{Indeterminate} &:& ({\tt CMO\_INDETERMINATE}, {\sl Cstring}\, {\rm v}) \\ & & \mbox{ --- Variable name $v$ . } \\ \end{eqnarray*} @@ -79,7 +117,10 @@ ZZ, QQ, Zero, Rational, Indeterminate,$\in$ CMObject/B /*&C */ +/*&C +*/ + /*&jp Indeterminate は変数名をあらわす. v はバイト列であればなにを用いてもよいが, @@ -92,52 +133,49 @@ escape sequence を用いて実現するのは, 無理があるようで テーブルを作成する必要があるであろう.) */ /*&eg -Indeterminate is a name of a variable. +The name of a variable should be expressed by using Indeterminate. v may be any sequence of bytes, but each system has its own restrictions on the names of variables. Indeterminates of CMO and internal variable names must be translated -in one to one correspondence. +in one-to-one correspondence. */ + /*&jp +\subsection{Indeterminate および Tree} \noindent -Group CMObject/Tree requires CMObject/Basic1. \\ -Tree, Lambda $\in$ CMObject/Basic1. \\ +Group CMObject/Tree requires CMObject/Basic. \\ +Tree, Lambda $\in$ CMObject/Tree. \\ \begin{eqnarray*} \mbox{Tree} &:& ({\tt CMO\_TREE}, {\sl Cstring}\, {\rm name}, - {\sl Cstring}\, {\rm cdname}, {\sl List}\, {\rm leaves}) \\ + {\sl List}\, {\rm attributes}, {\sl List}\, {\rm leaves}) \\ & & \mbox{ --- 名前 name の定数または関数. 関数の評価はおこなわない. } \\ -& & \mbox{ --- cdname は空文字列でなければ name の意味が説明されている }\\ -& & \mbox{ --- OpenMath CD (content dictionary) の名前. } \\ +& & \mbox{ --- attributes は空リストでなければ name の属性を保持している. }\\ +& & \mbox{ --- 属性リストは, key と 値のペアである. }\\ \mbox{Lambda} &:& ({\tt CMO\_LAMBDA}, {\sl List}\, {\rm args}, {\sl Tree} {\rm body}) \\ & & \mbox{ --- body を args を引数とする関数とする. } \\ -& & \mbox{ --- optional な引数が必要なときは, leaves の後へつづける.} \\ \end{eqnarray*} */ /*&eg +\subsection{Indeterminate and Tree} \noindent -Group CMObject/Tree requires CMObject/Basic1. \\ -Tree, Lambda $\in$ CMObject/Basic1. \\ +Group CMObject/Tree requires CMObject/Basic. \\ +Tree, Lambda $\in$ CMObject/Tree. \\ \begin{eqnarray*} \mbox{Tree} &:& ({\tt CMO\_TREE}, {\sl Cstring}\, {\rm name}, - {\sl Cstring}\, {\rm cdname}, {\sl List}\, {\rm leaves}) \\ -& & \mbox{ --- A function or a constant of name. Functions are not evaluated. } \\ -& & \mbox{ --- cdname may be a null. If it is not null, it is the name of}\\ -& & \mbox{ --- the OpenMath CD (content dictionary). } \\ + {\sl List}\, {\rm attributes}, {\sl List}\, {\rm leaves}) \\ +& & \mbox{ --- ``name'' is the name of the node of the tree. } \\ +& & \mbox{ --- Attributes may be a null list. If it is not null, it is a list of}\\ +& & \mbox{ --- key and value pairs. } \\ \mbox{Lambda} &:& ({\tt CMO\_LAMBDA}, {\sl List}\, {\rm args}, {\sl Tree} {\rm body}) \\ & & \mbox{ --- a function with the arguments body. } \\ -& & \mbox{ --- optional arguments come after leaves.} \\ \end{eqnarray*} */ -/*&C - -*/ - /*&jp 数式を処理するシステムでは, Tree 構造が一般にもちいられる. たとえば, $\sin(x+e)$ は, @@ -164,7 +202,17 @@ For example, $\sin(x+e)$ is expressed as {\tt (sin, (plus, x, e))} as a tree. -We can @@@ +Tree may be expressed by putting the expression between +{\tt SM\_beginBlock} and {\tt SM\_endBlock}, which are +stack machine commands for delayed evaluation. +(cf. {\tt \{ }, {\tt \} } in PostScript). +However it makes the implementation of stack machines complicated. +It is desirable that CMObject is independent of OX stack machine. +Therefore we introduce an OpenMath like tree representation for CMO +Tree object. +This method allows us to implement tree structure easily +on individual OpenXM systems. +Note that CMO Tree corresponds to Symbol and Application in OpenMath. */ @@ -174,40 +222,78 @@ We can @@@ /*&jp Lambda は関数を定義するための関数である. Lisp の Lambda 表現と同じ. +*/ +/*&eg +Lambda is used to define functions. +The notion ``lambda'' is borrowed from the language Lisp. +*/ \noindent -例: $sin(x+e)$ の表現. +//&jp 例: $sin(x+e)$ の表現. +//&eg Example: the expression of $sin(x+e)$. \begin{verbatim} -(CMO_TREE, (CMO_STRING, "sin"), (CMO_STRING, "basic"), +(CMO_TREE, (CMO_STRING, "sin"), + (CMO_LIST,[size=]1,(CMO_LIST,[size=]2,(CMO_STRING, "cdname"), + (CMO_STRING,"basic"))) (CMO_LIST,[size=]1, (CMO_TREE, (CMO_STRING, "plus"), (CMO_STRING, "basic"), (CMO_LIST,[size=]2, (CMO_INDETERMINATE,"x"), - (CMO_TREE,(CMO_STRING, "e"), 自然対数の底 - (CMO_STRING, "basic")) +//&jp (CMO_TREE,(CMO_STRING, "e"), 自然対数の底 +//&eg (CMO_TREE,(CMO_STRING, "e"), the base of natural logarithms + (CMO_LIST,[size=]1,(CMO_LIST,[size=]2,(CMO_STRING, "cdname"), + (CMO_STRING,"basic"))) )) ) ) \end{verbatim} +//&jp Leave の成分には, 多項式を含む任意のオブジェクトがきてよい. +//&eg Elements of the leave may be any objects including polynomials. \noindent Example: \begin{verbatim} -sm1> [(plus) (Basic) [(123).. (345)..]] [(class) (tree)] dc :: -Class.tree [ $plus$ , $Basic$ , [ 123 , 345 ] ] +sm1> [(plus) [[(cdname) (basic)]] [(123).. (345)..]] [(class) (tree)] dc :: +Class.tree [$plus$ , [[$cdname$ , $basic$ ]], [ 123 , 345 ] ] \end{verbatim} +\noindent +Example: +\begin{verbatim} +asir +[753] taka_cmo100_xml_form(quote(sin(x+1))); + "sin" + 1 + 2 + "cdname" + "basic" + + "plus" + 1 + 2 + "cdname" + "basic" + + "x" + 1 + +\end{verbatim} \bigbreak -次に, 分散表現多項式に関係するグループを定義しよう. +//&jp 次に, 分散表現多項式に関係するグループを定義しよう. +/*&eg +Let us define a group for distributed polynomials. In the following, +DMS stands for Distributed Monomial System. +*/ \medbreak \noindent -Group CMObject/DistributedPolynomials requires CMObject/Basic0, -CMObject/Basic1. \\ +Group CMObject/DistributedPolynomials requires CMObject/Primitive, +CMObject/Basic. \\ Monomial, Monomial32, Coefficient, Dpolynomial, DringDefinition, Generic DMS ring, RingByName, DMS of N variables $\in$ CMObject/DistributedPolynomials. \\ +/*&jp \begin{eqnarray*} \mbox{Monomial} &:& \mbox{Monomial32}\, |\, \mbox{Zero} \\ \mbox{Monomial32}&:& ({\tt CMO\_MONOMIAL32}, {\sl int32}\, n, @@ -219,7 +305,7 @@ $x^e = x_1^{e_1} \cdots x_n^{e_n}$ の各指数 $e_i$ をあらわす.} \\ \mbox{Coefficient}&:& \mbox{ZZ} | \mbox{Integer32} \\ \mbox{Dpolynomial}&:& \mbox{Zero} \\ -& & |\ ({\tt CMO\_DISTRIBUTED\_POLYNOMIAL},{\sl int32} m, \\ +& & |\ ({\tt CMO\_DISTRIBUTED\_POLYNOMIAL},{\sl int32}\, m, \\ & & \ \ \mbox{DringDefinition}, [\mbox{Monomial32}|\mbox{Zero}], \\ & &\ \ @@ -249,72 +335,153 @@ $x^e = x_1^{e_1} \cdots x_n^{e_n}$ の各指数 $e_i$ & & \mbox{ --- wvec は order をきめる weight vector,} \\ & & \mbox{ --- outord は出力するときの変数順序.} \\ \end{eqnarray*} +*/ +/*&eg +\begin{eqnarray*} +\mbox{Monomial} &:& \mbox{Monomial32}\, |\, \mbox{Zero} \\ +\mbox{Monomial32}&:& ({\tt CMO\_MONOMIAL32}, {\sl int32}\, n, + {\sl int32}\, \mbox{e[1]}, \ldots, + {\sl int32}\, \mbox{e[n]}, \\ + & & \ \mbox{Coefficient}) \\ + & & \mbox{ --- e[i] is the exponent $e_i$ of the monomial + $x^e = x_1^{e_1} \cdots x_n^{e_n}$. } \\ +\mbox{Coefficient}&:& \mbox{ZZ} | \mbox{Integer32} \\ +\mbox{Dpolynomial}&:& \mbox{Zero} \\ + & & |\ ({\tt CMO\_DISTRIBUTED\_POLYNOMIAL},{\sl int32}\, m, \\ + & & \ \ \mbox{DringDefinition}, [\mbox{Monomial32}|\mbox{Zero}], \\ + & &\ \ + \{\mbox{Monomial32}\}) \\ + & &\mbox{--- m is equal to the number of monomials.}\\ +\mbox{DringDefinition} + &:& \mbox{DMS of N variables} \\ + & & |\ \mbox{RingByName} \\ + & & |\ \mbox{Generic DMS ring} \\ + & & \mbox{ --- definition of the ring of distributed polynomials. } \\ +\mbox{Generic DMS ring} + &:& ({\tt CMO\_DMS\_GENERIC}) \\ +\mbox{RingByName}&:& ({\tt CMO\_RING\_BY\_NAME}, {\sl Cstring} s) \\ + & & \mbox{ --- The ring definition referred by the name ``s''.} \\ +\mbox{DMS of N variables} + &:& ({\tt CMO\_DMS\_OF\_N\_VARIABLES}, \\ + & & \ ({\tt CMO\_LIST}, {\sl int32}\, \mbox{m}, + {\sl Integer32}\, \mbox{n}, {\sl Integer32}\, \mbox{p} \\ + & & \ \ [,{\sl Cstring}\,\mbox{s}, {\sl List}\, \mbox{vlist}, + {\sl List}\, \mbox{wvec}, {\sl List}\, \mbox{outord}]) \\ + & & \mbox{ --- m is the number of elements.} \\ + & & \mbox{ --- n is the number of variables, p is the characteristic} \\ + & & \mbox{ --- s is the name of the ring, vlist is the list of variables.} \\ + & & \mbox{ --- wvec is the weight vector.} \\ + & & \mbox{ --- outord is the order of variables to output.} \\ +\end{eqnarray*} +*/ +/*&jp RingByName や DMS of N variables はなくても, DMS を定義できる. したがって, これらを実装してないシステムで DMS を扱うものが あってもかまわない. 以下, 以上の CMObject にたいする, xxx = asir, kan の振舞いを記述する. +*/ +/*&eg +Note that it is possible to define DMS without RingByName and +DMS of N variables. +In the following we describe how the above CMObjects +are implemented on Asir and Kan. +*/ + \subsection{ Zero} -CMO では ゼロの表現法がなんとうりもあるが, -どのようなゼロをうけとっても, -システムのゼロに変換できるべきである. -(たとえば, asir は 0 はただ一つ.) +/*&jp +CMO では ゼロの表現法がなんとおりもあることに注意. +%% どのようなゼロをうけとっても, +%% システムのゼロに変換できるべきである. +*/ +/*&eg +Note that CMO has various representations of zero. +*/ +//&jp \subsection{ 整数 ZZ } +//&eg \subsection{ Integer ZZ } -\subsection{ 整数 ZZ } - \begin{verbatim} #define CMO_ZZ 20 \end{verbatim} +/*&jp +この節ではOpen xxx 規約における任意の大きさの整数(bignum)の扱いについ +て説明する. Open XM 規約における多重精度整数を表すデータ型 CMO\_ZZ は +GNU MPライブラリなどを参考にして設計されていて, 符号付き絶対値表現を用 +いている. (cf. {\tt kan/sm1} の配布ディレクトリのなかの {\tt +plugin/cmo-gmp.c}) CMO\_ZZ は次の形式をとる. +*/ +/*&eg +We describe the bignum (multi-precision integer) representation +{\tt CMO\_ZZ} in OpenXM. +The format is similar +to that in GNU MP. (cf. {\tt plugin/cmo-gmp.c} in the {\tt kan/sm1} +distribution). CMO\_ZZ is defined as follows. +*/ -この節ではOpen xxx 規約における任意の大きさの整数(bignum)の扱いについて -説明する. -Open XM 規約における多重精度整数を表すデータ型 CMO\_ZZ は GNU MPライブ -ラリなどを参考にして設計されていて, 符号付き絶対値表現を用いている. -(cf. {\tt kan/sm1} の配布ディレクトリのなかの {\tt plugin/cmo-gmp.c}) -CMO\_ZZ は次の形式をとる.\\ \begin{tabular}{|c|c|c|c|c|} \hline {\tt int32 CMO\_ZZ} & {\tt int32 $f$} & {\tt int32 $b_0$} & $\cdots$ & {\tt int32 $b_{n}$} \\ \hline -\end{tabular} \\ -$f$ は32bit整数である. -$b_0, \ldots, b_n$ は unsigned int32 である. -$|f|$ は $n+1$ である. -この CMO の符号は $f$ の符号で定める. -前述したように, 32bit整数の負数は 2 の補数表現で表される. +\end{tabular} -Open xxx 規約では上の CMO は以下の整数を意味する. +/*&jp +$f$ は32bit整数である. $b_0, \ldots, b_n$ は unsigned int32 である. +$|f|$ は $n+1$ である. この CMO の符号は $f$ の符号で定める. 前述し +たように, 32bit整数の負数は 2 の補数表現で表される. + +Open xxx 規約では上の CMO は以下の整数を意味する. ($R = 2^{32}$) +*/ +/*&eg +$f$ is a 32bit integer. $b_0, \ldots, b_n$ are unsigned 32bit integers. +$|f|$ is equal to $n+1$. +The sign of $f$ represents that of the above integer to be expressed. +As stated in Section +\ref{sec:basic0}, a negative 32bit integer is represented by +two's complement. + +In OpenXM the above CMO represents the following integer. ($R = 2^{32}$.) +*/ + \[ \mbox{sgn}(f)\times (b_0 R^{0}+ b_1 R^{1} + \cdots + b_{n-1}R^{n-1} + b_n R^n). \] -ここで $R = 2^{32}$ である. -{\tt int32} を network byte order で表現しているとすると, -例えば, 整数 $14$ は CMO\_ZZ で表わすと, + +/*&jp +\noindent 例: +{\tt int32} を network byte order で表現 +しているとすると,例えば, 整数 $14$ は CMO\_ZZ で表わすと, +*/ +/*&eg +\noindent Example: +If we express {\tt int32} by the network byte order, +a CMO\_ZZ $14$ is expressed by +*/ \[ \mbox{(CMO\_ZZ, 1, 0, 0, 0, e)}, \] -と表わす. -これはバイト列では +//&jp と表わす. これはバイト列では +//&eg The corresponding byte sequence is \[ \mbox{\tt 00 00 00 14 00 00 00 01 00 00 00 0e} \] -となる. +//&jp となる. -なお ZZ の 0 ( (ZZ) 0 と書く ) は, -{\tt (CMO\_ZZ, 00,00,00,00)} -と表現する. +//&jp なお ZZ の 0 ( (ZZ) 0 と書く ) は, {\tt (CMO\_ZZ, 00,00,00,00)} と表現する. +//&eg Note that CMO\_ZZ 0 is expressed by {\tt (CMO\_ZZ, 00,00,00,00)}. -\subsection{ 分散表現多項式 Dpolynomial } +//&jp \subsection{ 分散表現多項式 Dpolynomial } +//&eg \subsection{ Distributed polynomial Dpolynomial } +/*&jp 環とそれに属する多項式は次のような考えかたであつかう. Generic DMS ring に属する元は, @@ -343,14 +510,35 @@ Ring by Name を用いた場合, 現在の名前空間で変数 yyy に {\tt kan/sm1} の場合, 環の定義は ring object として格納されており, この ring object を 変数 yyy で参照することにより CMO としてうけとった 多項式をこの ring の元として格納できる. +*/ +/*&eg +We treat polynomial rings and their elements as follows. +Generic DMS ring is an $n$-variate polynomial ring $K[x_1, \ldots, x_n]$, +where $K$ is a coefficient set. $K$ is unknown in advance +and it is determined when coefficients of an element are received. +When a server has received an element in Generic DMS ring, +the server has to translate it into the corresponding local object +on the server. Each server has its own translation scheme. +In Asir such an element are translated into a distributed polynomial. +In {\tt kan/sm1} things are complicated. +{\tt kan/sm1} does not have any class corresponding to Generic DMS ring. +{\tt kan/sm1} translates a DMS of N variables into an element of +the CurrentRing. +If the CurrentRing is $n'$-variate and $n' < n$, then +an $n$-variate polynomial ring is newly created. +If RingByName ({\tt CMO\_RING\_BY\_NAME}, yyy) +is specified as the second field of DMS, +it requests a sever to use a ring object whose name is yyy +as the destination ring for the translation. +*/ \medbreak \noindent -{\bf Example}: -(すべての数の表記は 16 進表記) +//&jp {\bf Example}: (すべての数の表記は 16 進表記) +//&eg {\bf Example}: (all numbers are represented in hexadecimal notation) {\footnotesize \begin{verbatim} Z/11Z [6 variables] (kxx/cmotest.sm1) run @@ -369,33 +557,33 @@ ff omc :: (CMO_DISTRIBUTED_POLYNOMIAL[1f],[size=]1,(CMO_DMS_GENERIC[18],), (CMO_MONOMIAL32[13],3*x^2*y),), \end{verbatim} } -length は, monomial の数$+2$ である. -$ 3 x^2 y$ は 6 変数の多項式環の元としてみなされている. -%%Prog: (3x^2 y). cmosave ===> debug/cmodata1.cmo -%%\\ 反省: 分散多項式の定義で, -%%{\tt CMO\_LIST} でなく, {\tt CMO\_DMS} がはじめにくるべきだったのでは? -%%あたらしい 分散多項式の定義は次のようにすべき: -%% 修正済み. 1999, 9/13 +/*&jp +$ 3 x^2 y$ は 6 変数の多項式環の 元としてみなされている. +*/ +/*&eg +$3 x^2 y$ is regarded as an element of a six-variate polynomial ring. +*/ +//&jp \subsection{再帰表現多項式の定義} +//&eg \subsection{Recursive polynomials} -\subsection{再帰表現多項式の定義} - \begin{verbatim} #define CMO_RECURSIVE_POLYNOMIAL 27 #define CMO_POLYNOMIAL_IN_ONE_VARIABLE 33 \end{verbatim} -Group CMObject/RecursivePolynomial requires CMObject/Basic0, CMObject/Basic1.\\ +Group CMObject/RecursivePolynomial requires CMObject/Primitive, CMObject/Basic.\\ Polynomial in 1 variable, Coefficient, Name of the main variable, Recursive Polynomial, Ring definition for recursive polynomials $\in$ CMObject/RecursivePolynomial \\ +/*&jp \begin{eqnarray*} \mbox{Polynomial in 1 variable} &:& \mbox{({\tt CMO\_POLYNOMIAL\_IN\_ONE\_VARIABLE},\, {\sl int32}\, m, } \\ & & \quad \mbox{ Name of the main variable }, \\ -& & \quad \mbox{ \{ {\sl int32} e, Coefficient \}} \\ +& & \quad \mbox{ \{ {\sl int32} e, Coefficient \}} ) \\ & & \mbox{ --- m はモノミアルの個数. } \\ & & \mbox{ --- e, Coefficieint はモノミアルを表現している. } \\ & & \mbox{ --- 順序の高い順にならべる. 普通は巾の高い順.} \\ @@ -409,19 +597,48 @@ $\in$ CMObject/RecursivePolynomial \\ & & \mbox{ --- v は 変数番号 (0 からはじまる) を表す. } \\ \mbox{Recursive Polynomial} &:& \mbox{ ( {\tt CMO\_RECURSIVE\_POLYNOMIAL}, } \\ -& & \quad \mbox{ Ring definition for -recursive polynomials, } \\ +& & \quad \mbox{ RringDefinition, } \\ & & \quad -\mbox{ Polynomial in 1 variable}\, | \, \mbox{Coefficient} \\ -\mbox{Ring definition for recursive polynomials } +\mbox{ Polynomial in 1 variable}\, | \, \mbox{Coefficient} ) \\ +\mbox{RringDefinition} & : & \mbox{ {\sl List} v } \\ -& & \quad \mbox{ --- v は, 変数名(indeterminate) のリスト. } \\ +& & \quad \mbox{ --- v は, 変数名(indeterminate) または Tree のリスト. } \\ & & \quad \mbox{ --- 順序の高い順. } \\ \end{eqnarray*} - +*/ +/*&eg +\begin{eqnarray*} +\mbox{Polynomial in 1 variable} &:& +\mbox{({\tt CMO\_POLYNOMIAL\_IN\_ONE\_VARIABLE},\, {\sl int32}\, m, } \\ +& & \quad \mbox{ Name of the main variable }, \\ +& & \quad \mbox{ \{ {\sl int32} e, Coefficient \}} ) \\ +& & \mbox{ --- m is the number of monomials. } \\ +& & \mbox{ --- A pair of e and Coefficient represents a monomial. } \\ +& & \mbox{ --- The pairs of e and Coefficient are sorted in the } \\ +& & \mbox{ \quad decreasing order, usually with respect to e.} \\ +& & \mbox{ --- e denotes an exponent of a monomial with respect to } \\ +& & \mbox{ \quad the main variable. } \\ +\mbox{Coefficient} &:& \mbox{ ZZ} \,|\, \mbox{ QQ } \,|\, +\mbox{ integer32 } \,|\, +\mbox{ Polynomial in 1 variable } \\ +& & \quad \,|\, \mbox{Tree} \,|\, \mbox{Zero} \,|\,\mbox{Dpolynomial}\\ +\mbox{Name of the main variable } &:& +\mbox{ {\sl int32} v } \\ +& & \mbox{ --- v denotes a variable number. } \\ +\mbox{Recursive Polynomial} &:& +\mbox{ ( {\tt CMO\_RECURSIVE\_POLYNOMIAL}, } \\ +& & \quad \mbox{ RringDefinition, } \\ +& & \quad +\mbox{ Polynomial in 1 variable}\, | \, \mbox{Coefficient} ) \\ +\mbox{RringDefinition} +& : & \mbox{ {\sl List} v } \\ +& & \quad \mbox{ --- v is a list of names of indeterminates or trees. } \\ +& & \quad \mbox{ --- It is sorted in the decreasing order. } \\ +\end{eqnarray*} +*/ \bigbreak \noindent -実例: +Example: \begin{verbatim} (CMO_RECURSIEVE_POLYNOMIAL, ("x","y"), (CMO_POLYNOMIAL_IN_ONE_VARIABLE, 2, 0, <--- "x" @@ -432,12 +649,21 @@ recursive polynomials, } \\ 10, 1, 5, 31))) \end{verbatim} -これは, -$$ x^3 (1234 y^5 + 17 ) + x^1 (y^10 + 31 y^5) $$ +//&jp これは, +//&eg This represents +$$ x^3 (1234 y^5 + 17 ) + x^1 (y^{10} + 31 y^5) $$ +/*&jp をあらわす. -非可換多項式もこの形式であらわしたいので, 積の順序を上のように -すること. つまり, 主変数かける係数の順番. +%%非可換多項式もこの形式であらわしたいので, 積の順序を上のように +%%すること. つまり, 主変数かける係数の順番. +*/ +/*&eg +%%We intend to represent non-commutative polynomials with the +%%same form. In such a case, the order of products are defined +%%as above, that is a power of the main variable $\times$ a coeffcient. +*/ + \noindent \begin{verbatim} sm1 @@ -446,16 +672,9 @@ sm1>ff :: Class.recursivePolynomial h * ((-1)) + (x^2 * (1)) \end{verbatim} +//&jp \subsection{CPU依存の double } +//&eg \subsection{CPU dependent double} - -int32 と Integer32 の違い. -次にくるデータがかならず int32 とわかっておれば, -int32 を用いる. -次のデータ型がわからないとき Integer32 を用いる. - - -\subsection{CPU依存の double } - \begin{verbatim} #define CMO_64BIT_MACHINE_DOUBLE 40 #define CMO_ARRAY_OF_64BIT_MACHINE_DOUBLE 41 @@ -464,60 +683,144 @@ int32 を用いる. \end{verbatim} \noindent -Group CMObject/MachineDouble requires CMObject/Basic0.\\ +Group CMObject/MachineDouble requires CMObject/Primitive.\\ 64bit machine double, Array of 64bit machine double 128bit machine double, Array of 128bit machine double $\in$ CMObject/MachineDouble \\ +/*&jp \begin{eqnarray*} \mbox{64bit machine double} &:& \mbox{({\tt CMO\_64BIT\_MACHINE\_DOUBLE}, } \\ -& & \quad \mbox{ {\sl byte} s1 , \ldots , {\sl byte}} s8)\\ +& & \quad \mbox{ {\sl byte} s1 , \ldots , {\sl byte} s8})\\ & & \mbox{ --- s1, $\ldots$, s8 は {\tt double} (64bit). } \\ & & \mbox{ --- この表現はCPU依存である.}\\ -&& \mbox{\quad\quad mathcap に CPU 情報を付加しておく.} \\ +&& \mbox{\quad\quad byte order negotiation を用いる.} \\ \mbox{Array of 64bit machine double} &:& \mbox{({\tt CMO\_ARRAY\_OF\_64BIT\_MACHINE\_DOUBLE}, {\sl int32} m, } \\ & & \quad \mbox{ {\sl byte} s1[1] , \ldots , {\sl byte}}\, s8[1], \ldots , {\sl byte}\, s8[m])\\ & & \mbox{ --- s*[1], $\ldots$ s*[m] は m 個の double (64bit) である. } \\ & & \mbox{ --- この表現はCPU依存である.}\\ -& & \mbox{ \quad\quad mathcap に CPU 情報を付加しておく.} \\ +& & \mbox{ \quad\quad byte order negotiation を用いる.} \\ \mbox{128bit machine double} &:& \mbox{({\tt CMO\_128BIT\_MACHINE\_DOUBLE}, } \\ -& & \quad \mbox{ {\sl byte} s1 , \ldots , {\sl byte}} s16)\\ +& & \quad \mbox{ {\sl byte} s1 , \ldots , {\sl byte} s16})\\ & & \mbox{ --- s1, $\ldots$, s16 は {\tt long double} (128bit). } \\ & & \mbox{ --- この表現はCPU依存である.}\\ -&& \mbox{\quad\quad mathcap に CPU 情報を付加しておく.} \\ +&& \mbox{\quad\quad byte order negotiation を用いる.} \\ \mbox{Array of 128bit machine double} &:& \mbox{({\tt CMO\_ARRAY\_OF\_128BIT\_MACHINE\_DOUBLE}, {\sl int32} m, } \\ -& & \quad \mbox{ {\sl byte} s1[1] , \ldots , {\sl byte}} s16[1], \ldots , {\sl byte} s16[m])\\ +& & \quad \mbox{ {\sl byte} s1[1] , \ldots , {\sl byte} s16[1], \ldots , {\sl byte} s16[m]})\\ & & \mbox{ --- s*[1], $\ldots$ s*[m] は m 個の long double (128bit) である. } \\ & & \mbox{ --- この表現はCPU依存である.}\\ -& & \mbox{ \quad\quad mathcap に CPU 情報を付加しておく.} +& & \mbox{ \quad\quad byte order negotiation を用いる.} \end{eqnarray*} +*/ +/*&eg +\begin{eqnarray*} +\mbox{64bit machine double} &:& +\mbox{({\tt CMO\_64BIT\_MACHINE\_DOUBLE}, } \\ +& & \quad \mbox{ {\sl byte} s1 , \ldots , {\sl byte} s8})\\ +& & \mbox{ --- s1, $\ldots$, s8 は {\tt double} (64bit). } \\ +& & \mbox{ --- Encoding depends on CPU.}\\ +&& \mbox{\quad\quad Need the byte order negotiation.} \\ +\mbox{Array of 64bit machine double} &:& +\mbox{({\tt CMO\_ARRAY\_OF\_64BIT\_MACHINE\_DOUBLE}, {\sl int32} m, } \\ +& & \quad \mbox{ {\sl byte} s1[1] , \ldots , {\sl byte}}\, s8[1], \ldots , {\sl byte}\, s8[m])\\ +& & \mbox{ --- s*[1], $\ldots$ s*[m] are 64bit double's. } \\ +& & \mbox{ --- Encoding depends on CPU.}\\ +& & \mbox{\quad\quad Need the byte order negotiation.} \\ +\mbox{128bit machine double} &:& +\mbox{({\tt CMO\_128BIT\_MACHINE\_DOUBLE}, } \\ +& & \quad \mbox{ {\sl byte} s1 , \ldots , {\sl byte} s16})\\ +& & \mbox{ --- s1, $\ldots$, s16 は {\tt long double} (128bit). } \\ +& & \mbox{ --- Encoding depends on CPU.}\\ +& & \mbox{\quad\quad Need the byte order negotiation.} \\ +\mbox{Array of 128bit machine double} &:& +\mbox{({\tt CMO\_ARRAY\_OF\_128BIT\_MACHINE\_DOUBLE}, {\sl int32} m, } \\ +& & \quad \mbox{ {\sl byte} s1[1] , \ldots , {\sl byte} s16[1], \ldots , {\sl byte} s16[m]})\\ +& & \mbox{ --- s*[1], $\ldots$ s*[m] are 128bit long double's. } \\ +& & \mbox{ --- Encoding depends on CPU.}\\ +& & \mbox{\quad\quad Need the byte order negotiation.} \\ +\end{eqnarray*} +*/ \bigbreak -次に IEEE 準拠の float および Big float を定義しよう. + \begin{verbatim} -#define CMO_BIGFLOAT 50 #define CMO_IEEE_DOUBLE_FLOAT 51 \end{verbatim} -IEEE 準拠の float については, -IEEE 754 double precision floating-point format -(64 bit) の定義を見よ. +/*&jp +IEEE 準拠の float については, IEEE 754 double precision floating-point +format (64 bit) の定義を見よ. -\noindent -Group CMObject/Bigfloat requires CMObject/Basic0, CMObject/Basic1.\\ -Bigfloat -$\in$ CMObject/Bigfloat \\ +256.100006 の Intel Pentium の double64 での内部表現は +{\tt cd 0c 80 43 } \\ +256.100006 の PowerPC (Mac) の double64 での内部表現は +{\tt 43 80 0c cd }. +この例でみるように byte の順序が逆である. +エンジンスタートの時の byte order negotiation で byte の順序を指定する. -\begin{eqnarray*} -\mbox{Bigfloat} &:& -\mbox{({\tt CMO\_BIGFLOAT}, } \\ -& & \quad \mbox{ {\sl ZZ} a , {\sl ZZ} e})\\ -& & \mbox{ --- $a \times 2^e$ をあらわす. } \\ -\end{eqnarray*} +*/ +/*&eg +See IEEE 754 double precision floating-point (64 bit) for the details of +float compliant to the IEEE standard. +The internal expression of 256.100006 in the Intel Pentium is +{\tt cd 0c 80 43 } \\ +The internal expression of 256.100006 in the PowerPC (Mac) is +{\tt 43 80 0c cd }. +As you have seen in this example, +the orders of the bytes are opposite each other. +The byte order is specified by the byte order negotiation protocol +when the engine starts. + */ + +\subsection{Bigfloat32} +/*&jp +int32 を基本とした bigfloat の表現方法について述べる. +この形式は mpfr を 32bit CPU で使用した時の内部表現と共通である. +*/ +/*&eg +This subsection describes our format for bigfloat in terms of the int32. +This format is identical to the internal format of mpfr on 32 bit CPU's. +*/ +Ref: {\tt OpenXM/src/mpfr/bfsize/bfsize.c} + +\begin{verbatim} +#define CMO_BIGFLOAT32 52 +\end{verbatim} + + +/*&jp +Bigfloat32 は次の形式の int32 の配列である. +*/ +/*&eg +The bigfloat32 is an array of int32 numbers of the following format. +*/ + +\begin{center} +{\sl int32}\, {\rm prec}, {\sl int32}\, {\rm sign}, {\sl int32}\, {\rm exp}, +{\sl int32}\, \mbox{a[1]}, \ldots , {\sl int32}\, \mbox{a[k]} +\end{center} + +/*&jp +p=prec は精度, s=sign は符号(1 が正の数, -1 (2の補数表現)が負の数) , +E=exp は指数部で, 上のデータは数 +$$ s (a[k]/B + a[k-1]/B^2 + ... + a[1]/B^k) 2^E $$ +を表す. +ここで $B=2^{32}$, +$k = \lceil p/32 \rceil$ +である. +*/ +/*&eg +p=prec is the precision, s=sign is the sign(1 means positive, -1 (expressed by two's complement) is nevative), +E=exp is the exponent, and the data above expresses the number +$$ s (a[k]/B + a[k-1]/B^2 + ... + a[1]/B^k) 2^E. $$ +Here, $B=2^{32}$, +$k = \lceil p/32 \rceil$. +*/ +