=================================================================== RCS file: /home/cvs/OpenXM/src/asir-doc/parts/builtin/array.texi,v retrieving revision 1.5 retrieving revision 1.13 diff -u -p -r1.5 -r1.13 --- OpenXM/src/asir-doc/parts/builtin/array.texi 2002/08/08 05:24:37 1.5 +++ OpenXM/src/asir-doc/parts/builtin/array.texi 2009/03/24 17:02:06 1.13 @@ -1,4 +1,4 @@ -@comment $OpenXM: OpenXM/src/asir-doc/parts/builtin/array.texi,v 1.4 2000/11/13 00:16:36 noro Exp $ +@comment $OpenXM: OpenXM/src/asir-doc/parts/builtin/array.texi,v 1.12 2009/03/24 08:21:45 ohara Exp $ \BJP @node 配列,,, 組み込み函数 @section 配列 @@ -9,24 +9,34 @@ \E @menu -* newvect:: -* newbytearray:: +* newvect vector vect:: +* ltov:: * vtol:: -* newmat:: +* newbytearray:: +* newmat matrix:: +* mat matr matc:: * size:: -* det invmat:: +* det nd_det invmat:: +* rowx rowm rowa colx colm cola:: + * qsort:: @end menu -\JP @node newvect,,, 配列 -\EG @node newvect,,, Arrays -@subsection @code{newvect} +\JP @node newvect vector vect,,, 配列 +\EG @node newvect vector vect,,, Arrays +@subsection @code{newvect}, @code{vector}, @code{vect} @findex newvect +@findex vector +@findex vect @table @t @item newvect(@var{len}[,@var{list}]) +@item vector(@var{len}[,@var{list}]) \JP :: 長さ @var{len} のベクトルを生成する. \EG :: Creates a new vector object with its length @var{len}. +@item vect([@var{elements}]) +\JP :: @var{elements} を要素とするベクトルを生成する. +\EG :: Creates a new vector object by @var{elements}. @end table @table @var @@ -39,12 +49,19 @@ @item list \JP リスト \EG list +@item elements +\JP 要素の並び +\EG elements of the vector @end table @itemize @bullet \BJP @item -長さ @var{len} のベクトルを生成する. 第 2 引数がない場合, +@code{vect} は要素の並びからベクトルを生成する. +@item +@code{vector} は @code{newvect} の別名である. +@item +@code{newvect} は長さ @var{len} のベクトルを生成する. 第 2 引数がない場合, 各成分は 0 に初期化される. 第 2 引数がある場合, インデックスの小さい成分から, リストの 各要素により初期化される. 各要素は, 先頭から順に @@ -70,8 +87,12 @@ を書き換えることができる. \E \BEG +@item +@code{vect} creates a new vector object by its elements. +@item +@code{vector} is an alias of @code{newvect}. @item -Creates a new vector object with its length @var{len} and its elements +@code{newvect} creates a new vector object with its length @var{len} and its elements all cleared to value 0. If the second argument, a list, is given, the vector is initialized by the list elements. @@ -135,18 +156,68 @@ separated simply by a `blank space', while those of a [5,6] [4] size(A); [5] -[5] def afo(V) @{ V[0] = x; @} -[6] afo(A)$ -[7] A; +[5] length(A); +5 +[6] vect(1,2,3,4,[5,6]); +[ 1 2 3 4 [5,6] ] +[7] def afo(V) @{ V[0] = x; @} +[8] afo(A)$ +[9] A; [ x 2 3 4 [5,6] ] @end example @table @t \JP @item 参照 \EG @item References -@fref{newmat}, @fref{size}, @fref{vtol}. +@fref{newmat matrix}, @fref{size}, @fref{ltov}, @fref{vtol}. @end table +\JP @node ltov,,, 配列 +\EG @node ltov,,, Arrays +@subsection @code{ltov} +@findex ltov + +@table @t +@item ltov(@var{list}) +\JP :: リストをベクトルに変換する. +\EG :: Converts a list into a vector. +@end table + +@table @var +@item return +\JP ベクトル +\EG vector +@item list +\JP リスト +\EG list +@end table + +@itemize @bullet +\BJP +@item +リスト @var{list} を同じ長さのベクトルに変換する. +@item +この関数は @code{newvect(length(@var{list}), @var{list})} に等しい. +\E +\BEG +@item +Converts a list @var{list} into a vector of same length. +See also @code{newvect()}. +\E +@end itemize + +@example +[3] A=[1,2,3]; +[4] ltov(A); +[ 1 2 3 ] +@end example + +@table @t +\JP @item 参照 +\EG @item References +@fref{newvect vector vect}, @fref{vtol}. +@end table + \JP @node vtol,,, 配列 \EG @node vtol,,, Arrays @subsection @code{vtol} @@ -194,7 +265,7 @@ A conversion from a list to a vector is done by @code{ @table @t \JP @item 参照 \EG @item References -@fref{newvect}. +@fref{newvect vector vect}, @fref{ltov}. @end table \JP @node newbytearray,,, 配列 @@ -250,16 +321,18 @@ similar to that of @code{newvect}. @table @t \JP @item 参照 \EG @item References -@fref{newvect}. +@fref{newvect vector vect}. @end table -\JP @node newmat,,, 配列 -\EG @node newmat,,, Arrays -@subsection @code{newmat} +\JP @node newmat matrix,,, 配列 +\EG @node newmat matrix,,, Arrays +@subsection @code{newmat}, @code{matrix} @findex newmat +@findex matrix @table @t -@item newmat(@var{row},@var{col} [,@var{[[a,b,}...@var{],[c,d,}...@var{],}...@var{]}]) +@item newmat(@var{row},@var{col} [,[[@var{a},@var{b},...],[@var{c},@var{d},...],...]]) +@item matrix(@var{row},@var{col} [,[[@var{a},@var{b},...],[@var{c},@var{d},...],...]]) \JP :: @var{row} 行 @var{col} 列の行列を生成する. \EG :: Creates a new matrix with @var{row} rows and @var{col} columns. @end table @@ -268,10 +341,10 @@ similar to that of @code{newvect}. @item return \JP 行列 \EG matrix -@item row,col +@item row col \JP 自然数 \EG non-negative integer -@item a,b,c,d +@item a b c d \JP 任意 \EG arbitrary @end table @@ -279,6 +352,8 @@ similar to that of @code{newvect}. @itemize @bullet \BJP @item +@code{matrix} は @code{newmat} の別名である. +@item @var{row} 行 @var{col} 列の行列を生成する. 第 3 引数がない場合, 各成分は 0 に初期化される. 第 3 引数がある場合, インデックスの小さい成分から, 各行が, リストの @@ -295,6 +370,8 @@ similar to that of @code{newvect}. を書き換えることができる. \E \BEG +@item +@code{matrix} is an alias of @code{newmat}. @item If the third argument, a list, is given, the newly created matrix is initialized so that each element of the list (again a list) @@ -337,9 +414,70 @@ return to toplevel @table @t \JP @item 参照 \EG @item References -@fref{newvect}, @fref{size}, @fref{det invmat}. +@fref{newvect vector vect}, @fref{size}, @fref{det nd_det invmat}. @end table +\JP @node mat matr matc,,, 配列 +\EG @node mat matr matc,,, Arrays +@subsection @code{mat}, @code{matr}, @code{matc} +@findex mat +@findex matr +@findex matc + +@table @t +@item mat(@var{vector}[,...]) +@item matr(@var{vector}[,...]) +\JP :: 行ベクトルの並びから行列を生成する. +\EG :: Creates a new matrix by list of row vectors. +@item matc(@var{vector}[,...]) +\JP :: 列ベクトルの並びから行列を生成する. +\EG :: Creates a new matrix by list of column vectors. +@end table + +@table @var +@item return +\JP 行列 +\EG matrix +@item @var{vector} +\JP 配列またはリスト +\EG array or list +@end table + +@itemize @bullet +\BJP +@item +@code{mat} は @code{matr} の別名である. +@item +引数の各ベクトルは同じ長さをもつ. +各要素は, 先頭から順に使われ, 足りない分は 0 が埋められる. +\E +\BEG +@item +@code{mat} is an alias of @code{matr}. +@item +Each vector has same length. +Elements are used from the first through the last. +If the list is short, 0's are filled in the remaining matrix elements. +\E +@end itemize + +@example +[0] matr([1,2,3],[4,5,6],[7,8]); +[ 1 2 3 ] +[ 4 5 6 ] +[ 7 8 0 ] +[1] matc([1,2,3],[4,5,6],[7,8]); +[ 1 4 7 ] +[ 2 5 8 ] +[ 3 6 0 ] +@end example + +@table @t +\JP @item 参照 +\EG @item References +@fref{newmat matrix} +@end table + \JP @node size,,, 配列 \EG @node size,,, Arrays @subsection @code{size} @@ -371,9 +509,11 @@ or a list containing row size and column size of the g @itemize @bullet \BJP @item -@var{vect} 又は, @var{mat} のサイズをリストで出力する. +@var{vect} の長さ, または @var{mat} の大きさをリストで出力する. @item -@var{list} のサイズは @code{length()}を, 有理式に現れる単項式の数は @code{nmono()} を用いる. +@var{vect} の長さは @code{length()} で求めることもできる. +@item +@var{list} の長さは @code{length()}を, 有理式に現れる単項式の数は @code{nmono()} を用いる. \E \BEG @item @@ -392,10 +532,12 @@ in a rational expression. [ 0 0 0 0 ] [1] size(A); [4] -[2] B = newmat(2,3,[[1,2,3],[4,5,6]]); +[2] length(A); +4 +[3] B = newmat(2,3,[[1,2,3],[4,5,6]]); [ 1 2 3 ] [ 4 5 6 ] -[3] size(B); +[4] size(B); [2,3] @end example @@ -405,18 +547,20 @@ in a rational expression. @fref{car cdr cons append reverse length}, @fref{nmono}. @end table -\JP @node det invmat,,, 配列 -\EG @node det invmat,,, Arrays -@subsection @code{det},@code{invmat} +\JP @node det nd_det invmat,,, 配列 +\EG @node det nd_det invmat,,, Arrays +@subsection @code{det}, @code{nd_det}, @code{invmat} @findex det +@findex nd_det @findex invmat @table @t @item det(@var{mat}[,@var{mod}]) +@itemx nd_det(@var{mat}[,@var{mod}]) \JP :: @var{mat} の行列式を求める. \EG :: Determinant of @var{mat}. @item invmat(@var{mat}) -\JP :: @var{mat} の行列式を求める. +\JP :: @var{mat} の逆行列を求める. \EG :: Inverse matrix of @var{mat}. @end table @@ -435,7 +579,7 @@ in a rational expression. @itemize @bullet \BJP @item -@code{det} は行列 @var{mat} の行列式を求める. +@code{det} および @code{nd_det} は行列 @var{mat} の行列式を求める. @code{invmat} は行列 @var{mat} の逆行列を求める. 逆行列は @code{[分母, 分子]} の形で返され, @code{分母}が行列, @code{分母/分子} が逆行列となる. @item @@ -443,10 +587,15 @@ in a rational expression. @item 分数なしのガウス消去法によっているため, 多変数多項式を成分とする 行列に対しては小行列式展開による方法のほうが効率がよい場合もある. +@item +@code{nd_det} は有理数または有限体上の多項式行列の行列式 +計算専用である. アルゴリズムはやはり分数なしのガウス消去法だが, +データ構造および乗除算の工夫により, 一般に @code{det} より高速に +計算できる. \E \BEG @item -@code{det} computes the determinant of matrix @var{mat}. +@code{det} and @code{nd_det} compute the determinant of matrix @var{mat}. @code{invmat} computes the inverse matrix of matrix @var{mat}. @code{invmat} returns a list @code{[num,den]}, where @code{num} is a matrix and @code{num/den} represents the inverse matrix. @@ -456,6 +605,11 @@ The computation is done over GF(@var{mod}) if @var{mod The fraction free Gaussian algorithm is employed. For matrices with multi-variate polynomial entries, minor expansion algorithm sometimes is more efficient than the fraction free Gaussian algorithm. +@item +@code{nd_det} can be used for computing the determinant of a matrix with +polynomial entries over the rationals or finite fields. The algorithm +is an improved vesion of the fraction free Gaussian algorithm +and it computes the determinant faster than @code{det}. \E @end itemize @@ -471,8 +625,8 @@ is more efficient than the fraction free Gaussian algo [ 1 u u^2 u^3 u^4 ] [ 1 v v^2 v^3 v^4 ] [95] fctr(det(A)); -[[1,1],[u-v,1],[-z+v,1],[-z+u,1],[-y+u,1],[y-v,1],[-y+z,1],[-x+u,1],[-x+z,1], -[-x+v,1],[-x+y,1]] +[[1,1],[u-v,1],[-z+v,1],[-z+u,1],[-y+u,1],[y-v,1],[-y+z,1],[-x+u,1], +[-x+z,1],[-x+v,1],[-x+y,1]] [96] A = newmat(3,3)$ [97] for(I=0;I<3;I++)for(J=0,B=A[I],W=V[I];J<3;J++)B[J]=W^J; [98] A; @@ -496,7 +650,7 @@ is more efficient than the fraction free Gaussian algo @table @t \JP @item 参照 \EG @item References -@fref{newmat}. +@fref{newmat matrix}. @end table \JP @node qsort,,, 配列 @@ -565,4 +719,86 @@ are exchanged. \JP @item 参照 \EG @item References @fref{ord}, @fref{vars}. +@end table + +\JP @node rowx rowm rowa colx colm cola,,, 配列 +\EG @node rowx rowm rowa colx colm cola,,, Arrays +@subsection @code{rowx}, @code{rowm}, @code{rowa}, @code{colx}, @code{colm}, @code{cola} +@findex rowx +@findex rowm +@findex rowa +@findex colx +@findex colm +@findex cola + +@table @t +@item rowx(@var{matrix},@var{i},@var{j}) +\JP :: 第 @var{i} 行と第 @var{j} 行を交換する. +\EG :: Exchanges the @var{i}-th and @var{j}-th rows. +@item rowm(@var{matrix},@var{i},@var{c}) +\JP :: 第 @var{i} 行を @var{c} 倍する. +\EG :: Multiplies the @var{i}-th row by @var{c}. +@item rowa(@var{matrix},@var{i},@var{c}) +\JP :: 第 @var{i} 行に第 @var{i} 行の @var{c} 倍を加える. +\EG :: Appends @var{c} times the @var{j}-th row to the @var{j}-th row. +@item colx(@var{matrix},@var{i},@var{j}) +\JP :: 第 @var{i} 行と第 @var{j} 行を交換する. +\EG :: Exchanges the @var{i}-th and @var{j}-th columns. +@item colm(@var{matrix},@var{i},@var{c}) +\JP :: 第 @var{i} 行を @var{c} 倍する. +\EG :: Multiplies the @var{i}-th column by @var{c}. +@item cola(@var{matrix},@var{i},@var{c}) +\JP :: 第 @var{i} 行に第 @var{i} 行の @var{c} 倍を加える. +\EG :: Appends @var{c} times the @var{j}-th column to the @var{j}-th column. +@end table + +@table @var +@item return +\JP 行列 +\EG matrix +@item @var{i}, @var{j} +\JP 整数 +\EG integers +@item @var{c} +\JP 係数 +\EG coefficient +@end table + +@itemize @bullet +\BJP +@item +行列の基本変形を行うための関数である. +@item +行列が破壊されることに注意する. +\E +\BEG +@item +These operations are destructive for the matrix. +\E +@end itemize + +@example +[0] A=newmat(3,3,[[1,2,3],[4,5,6],[7,8,9]]); +[ 1 2 3 ] +[ 4 5 6 ] +[ 7 8 9 ] +[1] rowx(A,1,2)$ +[2] A; +[ 1 2 3 ] +[ 7 8 9 ] +[ 4 5 6 ] +[3] rowm(A,2,x); +[ 1 2 3 ] +[ 7 8 9 ] +[ 4*x 5*x 6*x ] +[4] rowa(A,0,1,z); +[ 7*z+1 8*z+2 9*z+3 ] +[ 7 8 9 ] +[ 4*x 5*x 6*x ] +@end example + +@table @t +\JP @item 参照 +\EG @item References +@fref{newmat matrix} @end table