=================================================================== RCS file: /home/cvs/OpenXM/src/asir-doc/parts/builtin/upoly.texi,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -p -r1.1.1.1 -r1.2 --- OpenXM/src/asir-doc/parts/builtin/upoly.texi 1999/12/08 05:47:44 1.1.1.1 +++ OpenXM/src/asir-doc/parts/builtin/upoly.texi 1999/12/21 02:47:34 1.2 @@ -1,5 +1,12 @@ +@comment $OpenXM$ +\BJP @node 一変数多項式の演算,,, 組み込み函数 @section 一変数多項式の演算 +\E +\BEG +@node Univariate polynomials,,, Built-in Function +@section Univariate polynomials +\E @menu * umul umul_ff usquare usquare_ff utmul utmul_ff:: @@ -10,7 +17,8 @@ * udiv urem urembymul urembymul_precomp ugcd:: @end menu -@node umul umul_ff usquare usquare_ff utmul utmul_ff,,, 一変数多項式の演算 +\JP @node umul umul_ff usquare usquare_ff utmul utmul_ff,,, 一変数多項式の演算 +\EG @node umul umul_ff usquare usquare_ff utmul utmul_ff,,, Univariate polynomials @subsection @code{umul}, @code{umul_ff}, @code{usquare}, @code{usquare_ff}, @code{utmul}, @code{utmul_ff} @findex umul @findex umul_ff @@ -22,25 +30,32 @@ @table @t @item umul(@var{p1},@var{p2}) @itemx umul_ff(@var{p1},@var{p2}) -:: 一変数多項式の高速乗算 +\JP :: 一変数多項式の高速乗算 +\EG :: Fast multiplication of univariate polynomials @item usquare(@var{p1}) @itemx usquare_ff(@var{p1}) -:: 一変数多項式の高速 2 乗算 +\JP :: 一変数多項式の高速 2 乗算 +\EG :: Fast squaring of a univariate polynomial @item utmul(@var{p1},@var{p2},@var{d}) @itemx utmul_ff(@var{p1},@var{p2},@var{d}) -:: 一変数多項式の高速乗算 (打ち切り次数指定) +\JP :: 一変数多項式の高速乗算 (打ち切り次数指定) +\EG :: Fast multiplication of univariate polynomials with truncation @end table @table @var @item return -一変数多項式 +\JP 一変数多項式 +\EG univariate polynomial @item p1 p2 -一変数多項式 +\JP 一変数多項式 +\EG univariate polynomial @item d -非負整数 +\JP 非負整数 +\EG non-negative integer @end table @itemize @bullet +\BJP @item 一変数多項式の乗算を, 次数に応じて決まるアルゴリズムを用いて 高速に行う. @@ -51,7 +66,7 @@ @item @code{umul_ff()}, @code{usquare_ff()}, @code{utmul_ff()} は, 係数を有限体の元と見なして, 有限体上の多項式として -積を求める. ただし, 引数が全く有限体の元を含まない場合には, +積を求める. ただし, 引数の係数が整数の場合, 整数係数の多項式を返す場合もあるので, これらを呼び出した結果 が有限体係数であることを保証するためには あらかじめ @code{simp_ff()} で係数を有限体の元に変換しておくとよい. @@ -66,13 +81,53 @@ GF(2^n) 係数の多項式を引数に取れない. @item いずれも, @code{set_upkara()} (@code{utmul}, @code{utmul_ff} については @code{set_uptkara()}) で返される値以下の次数に対しては通常の筆算 -形式の方法, @code{set_uufft()} で返される値以下の次数に対しては Karatsuba +形式の方法, @code{set_upfft()} で返される値以下の次数に対しては Karatsuba 法, それ以上では FFTおよび中国剰余定理が用いられる. すなわち, 整数に対する FFT ではなく, 十分多くの 1 ワード以内の法 @var{mi} を用意し, @var{p1}, @var{p2} の係数を @var{mi} で割った余りとしたものの積を, FFT で計算し, 最後に中国剰余定理で合成する. その際, 有限体版の関数に おいては, 最後に基礎体を表す法で各係数の剰余を計算するが, ここでは -Shoup によるトリックを用いて高速化してある. +Shoup によるトリック @code{[Shoup]} を用いて高速化してある. +\E +\BEG +@item +These functions compute products of univariate polynomials +by selecting an appropriate algorithm depending on the degrees +of inputs. +@item +@code{umul()}, @code{usquare()}, @code{utmul()} +compute products over the integers. +Coefficients in GF(p) are regarded as non-negative integers +less than p. +@item +@code{umul_ff()}, @code{usquare_ff()}, @code{utmul_ff()} +compute products over a finite field. However, if some of +the coefficients of the inputs are integral, +the result may be an integral polynomial. So if one wants +to assure that the result is a polynomial over the finite field, +apply @code{simp_ff()} to the inputs. +@item +@code{umul_ff()}, @code{usquare_ff()}, @code{utmul_ff()} +cannot take polynomials over GF(2^n) as their inputs. +@item +@code{umul()}, @code{umul_ff()} produce @var{p1*p2}. +@code{usquare()}, @code{usquare_ff()} produce @var{p1^2}. +@code{utmul()}, @code{utmul_ff()} produce @var{p1*p2 mod v^(d+1)}, +where @var{v} is the variable of @var{p1}, @var{p2}. +@item +If the degrees of the inputs are less than or equal to the +value returned by @code{set_upkara()} (@code{set_uptkara()} for +@code{utmul}, @code{utmul_ff}), usual pencil and paper method is +used. If the degrees of the inputs are less than or equall to +the value returned by @code{set_upfft()}, Karatsuba algorithm +is used. If the degrees of the inputs exceed it, a combination +of FFT and Chinese remainder theorem is used. +First of all sufficiently many primes @var{mi} +within 1 machine word are prepared. +Then @var{p1*p2 mod mi} is computed by FFT for each @var{mi}. +Finally they are combined by Chinese remainder theorem. +The functions over finite fields use an improvement by V. Shoup @code{[Shoup]}. +\E @end itemize @example @@ -101,12 +156,14 @@ Shoup によるトリックを用いて高速化してある. @end example @table @t -@item 参照 +\JP @item 参照 +\EG @item References @fref{set_upkara set_uptkara set_upfft}, @fref{kmul ksquare ktmul}. @end table -@node kmul ksquare ktmul,,, 一変数多項式の演算 +\JP @node kmul ksquare ktmul,,, 一変数多項式の演算 +\EG @node kmul ksquare ktmul,,, Univariate polynomials @subsection @code{kmul}, @code{ksquare}, @code{ktmul} @findex kmul @findex ksquare @@ -114,23 +171,30 @@ Shoup によるトリックを用いて高速化してある. @table @t @item kmul(@var{p1},@var{p2}) -:: 一変数多項式の高速乗算 +\JP :: 一変数多項式の高速乗算 +\EG :: Fast multiplication of univariate polynomials @item ksquare(@var{p1}) -:: 一変数多項式の高速 2 乗算 +\JP :: 一変数多項式の高速 2 乗算 +\EG :: Fast squaring of a univariate polynomial @item ktmul(@var{p1},@var{p2},@var{d}) -:: 一変数多項式の高速乗算 (打ち切り次数指定) +\JP :: 一変数多項式の高速乗算 (打ち切り次数指定) +\EG :: Fast multiplication of univariate polynomials with truncation @end table @table @var @item return -一変数多項式 +\JP 一変数多項式 +\EG univariate polynomial @item p1 p2 -一変数多項式 +\JP 一変数多項式 +\EG univariate polynomial @item d -非負整数 +\JP 非負整数 +\EG non-negative integer @end table @itemize @bullet +\BJP @item 一変数多項式の乗算を Karatsuba 法で行う. @item @@ -138,6 +202,15 @@ Shoup によるトリックを用いて高速化してある. FFT を用いた高速化は行わない. @item GF(2^n) 係数の多項式にも用いることができる. +\E +\BEG +These functions compute products of univariate polynomials by Karatsuba +algorithm. +@item +These functions do not apply FFT for large degree inputs. +@item +These functions can compute products over GF(2^n). +\E @end itemize @example @@ -153,7 +226,8 @@ return to toplevel [37] kmul(A,B)$ @end example -@node set_upkara set_uptkara set_upfft,,, 一変数多項式の演算 +\JP @node set_upkara set_uptkara set_upfft,,, 一変数多項式の演算 +\EG @node set_upkara set_uptkara set_upfft,,, Univariate polynomials @subsection @code{set_upkara}, @code{set_uptkara}, @code{set_upfft} @findex set_upkara @findex set_uptkara @@ -163,17 +237,24 @@ return to toplevel @item set_upkara([@var{threshold}]) @itemx set_uptkara([@var{threshold}]) @itemx set_upfft([@var{threshold}]) -:: 1 変数多項式の積演算における N^2 , Karatsuba, FFT アルゴリズムの切替えの閾値 +\JP :: 1 変数多項式の積演算における N^2 , Karatsuba, FFT アルゴリズムの切替えの閾値 +\BEG +:: Set thresholds in the selection of an algorithm from N^2, Karatsuba, +FFT algorithms for univariate polynomial multiplication. +\E @end table @table @var @item return -設定されている値 +\JP 設定されている値 +\EG value currently set @item threshold -非負整数 +\JP 非負整数 +\EG non-negative integer @end table @itemize @bullet +\BJP @item いずれも, 一変数多項式の積の計算における, アルゴリズム切替えの閾値を 設定する. @@ -183,15 +264,29 @@ return to toplevel される. この切替えの次数を設定する. @item 詳細は, それぞれの積関数の項を参照のこと. +\E +\BEG +@item +These functions set thresholds in the selection of an algorithm from N^2, +Karatsuba, FFT algorithms for univariate polynomial multiplication. +@item +Products of univariate polynomials are computed by N^2, Karatsuba, +FFT algorithms. The algorithm selection is done according to the degrees of +input polynomials and the thresholds. +@item +See the description of each function for details. +\E @end itemize @table @t -@item 参照 +\JP @item 参照 +\EG @item References @fref{kmul ksquare ktmul}, @fref{umul umul_ff usquare usquare_ff utmul utmul_ff}. @end table -@node utrunc udecomp ureverse,,, 一変数多項式の演算 +\JP @node utrunc udecomp ureverse,,, 一変数多項式の演算 +\EG @node utrunc udecomp ureverse,,, Univariate polynomials @subsection @code{utrunc}, @code{udecomp}, @code{ureverse} @findex utrunc @findex udecomp @@ -201,19 +296,24 @@ return to toplevel @item utrunc(@var{p},@var{d}) @itemx udecomp(@var{p},@var{d}) @itemx ureverse(@var{p}) -:: 多項式に対する操作 +\JP :: 多項式に対する操作 +\EG :: Operations on polynomials @end table @table @var @item return -一変数多項式あるいは一変数多項式のリスト +\JP 一変数多項式あるいは一変数多項式のリスト +\EG univariate polynomial or list of univariate polynomials @item p -一変数多項式 +\JP 一変数多項式 +\EG univariate polynomial @item d -非負整数 +\JP 非負整数 +\EG non-negative integer @end table @itemize @bullet +\BJP @item @var{p} の変数を x とする. このとき @var{p} = @var{p1}+x^(d+1)@var{p2} (@var{p1} の次数は @var{d} 以下) と分解できる. @code{utrunc()} は @@ -221,6 +321,19 @@ return to toplevel @item @var{p} の次数を @var{e} とし, @var{i} 次の係数を @var{p[i]} とすれば, @code{ureverse()} は @var{p[e]}+@var{p[e-1]}x+... を返す. +\E +\BEG +@item +Let @var{x} be the variable of @var{p}. Then @var{p} can be decomposed +as @var{p} = @var{p1}+x^(d+1)@var{p2}, where the degree of @var{p1} +is less than or equal to @var{d}. +Under the decomposition, @code{utrunc()} returns +@var{p1} and @code{udecomp()} returns [@var{p1},@var{p2}]. +@item +Let @var{e} be the degree of @var{p} and @var{p[i]} the coefficient +of @var{p} at degree @var{i}. Then +@code{ureverse()} returns @var{p[e]}+@var{p[e-1]}x+.... +\E @end itemize @example @@ -233,11 +346,13 @@ return to toplevel @end example @table @t -@item 参照 +\JP @item 参照 +\EG @item References @fref{udiv urem urembymul urembymul_precomp ugcd}. @end table -@node uinv_as_power_series ureverse_inv_as_power_series,,, 一変数多項式の演算 +\JP @node uinv_as_power_series ureverse_inv_as_power_series,,, 一変数多項式の演算 +\EG @node uinv_as_power_series ureverse_inv_as_power_series,,, Univariate polynomials @subsection @code{uinv_as_power_series}, @code{ureverse_inv_as_power_series} @findex uinv_as_power_series @findex ureverse_inv_as_power_series @@ -245,19 +360,24 @@ return to toplevel @table @t @item uinv_as_power_series(@var{p},@var{d}) @itemx ureverse_inv_as_power_series(@var{p},@var{d}) -:: 多項式を冪級数とみて, 逆元計算 +\JP :: 多項式を冪級数とみて, 逆元計算 +\EG :: Computes the truncated inverse as a power series. @end table @table @var @item return -一変数多項式 +\JP 一変数多項式 +\EG univariate polynomial @item p -一変数多項式 +\JP 一変数多項式 +\EG univariate polynomial @item d -非負整数 +\JP 非負整数 +\EG non-negative integer @end table @itemize @bullet +\BJP @item @code{uinv_as_power_series(@var{p},@var{d})} は, 定数項が 0 でない 多項式 @var{p} に対し, @var{p}@var{r}-1 の最低次数が @var{d}+1 @@ -268,6 +388,23 @@ return to toplevel に対して @code{uinv_as_power_series(@var{p1},@var{d})} を計算する. @item @code{rembymul_precomp()} の引数として用いる場合, @code{ureverse_inv_as_power_series()} の結果をそのまま用いることができる. +\E +\BEG +@item +For a polynomial @var{p} with a non zero constant term, +@code{uinv_as_power_series(@var{p},@var{d})} computes +a polynomial @var{r} whose degree is at most @var{d} +such that @var{p*r = 1 mod x^(d+1)}, where @var{x} is the variable +of @var{p}. +@item +Let @var{e} be the degree of @var{p}. +@code{ureverse_inv_as_power_series(@var{p},@var{d})} computes +@code{uinv_as_power_series(@var{p1},@var{d})} for +@var{p1}=@code{ureverse(@var{p},@var{e})}. +@item +The output of @code{ureverse_inv_as_power_series()} can be used +as the input of @code{rembymul_precomp()}. +\E @end itemize @example @@ -286,12 +423,14 @@ x^10+x^9 @end example @table @t -@item 参照 +\JP @item 参照 +\EG @item References @fref{utrunc udecomp ureverse}, @fref{udiv urem urembymul urembymul_precomp ugcd}. @end table -@node udiv urem urembymul urembymul_precomp ugcd,,, 一変数多項式の演算 +\JP @node udiv urem urembymul urembymul_precomp ugcd,,, 一変数多項式の演算 +\EG @node udiv urem urembymul urembymul_precomp ugcd,,, Univariate polynomials @subsection @code{udiv}, @code{urem}, @code{urembymul}, @code{urembymul_precomp}, @code{ugcd} @findex udiv @findex urem @@ -305,17 +444,21 @@ x^10+x^9 @item urembymul(@var{p1},@var{p2}) @item urembymul_precomp(@var{p1},@var{p2},@var{inv}) @item ugcd(@var{p1},@var{p2}) -:: 多項式に対する操作 +\JP :: 一変数多項式の除算, GCD +\EG :: Division and GCD for univariate polynomials. @end table @table @var @item return -一変数多項式 +\JP 一変数多項式 +\EG univariate polynomial @item p1,p2,inv -一変数多項式 +\JP 一変数多項式 +\EG univariate polynomial @end table @itemize @bullet +\BJP @item 一変数多項式 @var{p1}, @var{p2} に対し, @code{udiv} は商, @code{urem}, @code{urembymul} は剰余, @@ -324,8 +467,29 @@ x^10+x^9 @code{urembymul} は, @var{p2} による剰余計算を, @var{p2} の 冪級数としての逆元計算および, 乗算 2 回に置き換えたもので, 次数が大きい場合に有効である. -@item @code{urembymul_precomp} は, 固定された多項式による剰余 +@item +@code{urembymul_precomp} は, 固定された多項式による剰余 計算を多数行う場合などに効果を発揮する. +第 3 引数は, あらかじめ @code{ureverse_inv_as_power_series()} に +より計算しておく. +\E +\BEG +@item +For univariate polynomials @var{p1} and @var{p2}, +there exist polynomials @var{q} and @var{r} such that +@var{p1=q*p2+r} and the degree of @var{r} is less than that of @var{p2}. +Then @code{udiv} returns @var{q}, @code{urem} and @code{urembymul} return +@var{r}. @code{ugcd} returns the polynomial GCD of @var{p1} and @var{p2}. +These functions are specially tuned up for dense univariate polynomials. +In @code{urembymul} the division by @var{p2} is replaced with +the inverse computation of @var{p2} as a power series and +two polynomial multiplications. It speeds up the computation +when the degrees of inputs are large. +@item +@code{urembymul_precomp} is efficient when one repeats divisions +by a fixed polynomial. +One has to compute the third argument by @code{ureverse_inv_as_power_series()}. +\E @end itemize @example @@ -348,6 +512,7 @@ x^10+x^9 @end example @table @t -@item 参照 +\JP @item 参照 +\EG @item References @fref{uinv_as_power_series ureverse_inv_as_power_series}. @end table