| version 1.1.1.1, 1999/12/08 05:47:44 |
version 1.3, 2000/02/05 12:01:09 |
|
|
| |
@comment $OpenXM: OpenXM/src/asir-doc/parts/builtin/array.texi,v 1.2 1999/12/21 02:47:33 noro Exp $ |
| |
\BJP |
| @node $BG[Ns(B,,, $BAH$_9~$_H!?t(B |
@node $BG[Ns(B,,, $BAH$_9~$_H!?t(B |
| @section $BG[Ns(B |
@section $BG[Ns(B |
| |
\E |
| |
\BEG |
| |
@node Arrays,,, Built-in Function |
| |
@section Arrays |
| |
\E |
| |
|
| @menu |
@menu |
| * newvect:: |
* newvect:: |
|
|
| * qsort:: |
* qsort:: |
| @end menu |
@end menu |
| |
|
| @node newvect,,, $BG[Ns(B |
\JP @node newvect,,, $BG[Ns(B |
| |
\EG @node newvect,,, Arrays |
| @subsection @code{newvect} |
@subsection @code{newvect} |
| @findex newvect |
@findex newvect |
| |
|
| @table @t |
@table @t |
| @item newvect(@var{len}[,@var{list}]) |
@item newvect(@var{len}[,@var{list}]) |
| :: $BD9$5(B @var{len} $B$N%Y%/%H%k$r@8@.$9$k(B. |
\JP :: $BD9$5(B @var{len} $B$N%Y%/%H%k$r@8@.$9$k(B. |
| |
\EG :: Creates a new vector object with its length @var{len}. |
| @end table |
@end table |
| |
|
| @table @var |
@table @var |
| @item return |
@item return |
| $B%Y%/%H%k(B |
\JP $B%Y%/%H%k(B |
| |
\EG vector |
| @item len |
@item len |
| $B<+A3?t(B |
\JP $B<+A3?t(B |
| |
\EG non-negative integer |
| @item list |
@item list |
| $B%j%9%H(B |
\JP $B%j%9%H(B |
| |
\EG list |
| @end table |
@end table |
| |
|
| @itemize @bullet |
@itemize @bullet |
| |
\BJP |
| @item |
@item |
| $BD9$5(B @var{len} $B$N%Y%/%H%k$r@8@.$9$k(B. $BBh(B 2 $B0z?t$,$J$$>l9g(B, |
$BD9$5(B @var{len} $B$N%Y%/%H%k$r@8@.$9$k(B. $BBh(B 2 $B0z?t$,$J$$>l9g(B, |
| $B3F@.J,$O(B 0 $B$K=i4|2=$5$l$k(B. $BBh(B 2 $B0z?t$,$"$k>l9g(B, |
$B3F@.J,$O(B 0 $B$K=i4|2=$5$l$k(B. $BBh(B 2 $B0z?t$,$"$k>l9g(B, |
|
|
| @item |
@item |
| $BH!?t$N0z?t$H$7$F%Y%/%H%k$rEO$7$?>l9g(B, $BEO$5$l$?H!?t$O(B, $B$=$N%Y%/%H%k$N@.J,(B |
$BH!?t$N0z?t$H$7$F%Y%/%H%k$rEO$7$?>l9g(B, $BEO$5$l$?H!?t$O(B, $B$=$N%Y%/%H%k$N@.J,(B |
| $B$r=q$-49$($k$3$H$,$G$-$k(B. |
$B$r=q$-49$($k$3$H$,$G$-$k(B. |
| |
\E |
| |
\BEG |
| |
@item |
| |
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. |
| |
Elements are used from the first through the last. |
| |
If the list is short for initializing the full vector, |
| |
0's are filled in the remaining vector elements. |
| |
@item |
| |
Elements are indexed from 0 through @var{len}-1. Note that the first |
| |
element has not index 1. |
| |
@item |
| |
List and vector are different types in @b{Asir}. |
| |
Lists are conveniently used for representing many data objects whose |
| |
size varies dynamically as computation proceeds. |
| |
By its flexible expressive power, it is also conveniently used to |
| |
describe initial values for other structured objects as you see |
| |
for vectors. |
| |
Access for an element of a list is performed by following pointers to |
| |
next elements. By this, access costs for list elements differ for |
| |
each element. |
| |
In contrast to lists, vector elements can be accessed in a same time, |
| |
because they are accessed by computing displacements from the top memory |
| |
location of the vector object. |
| |
|
| |
Note also, in @b{Asir}, modification of an element of a vector causes |
| |
modification of the whole vector itself, |
| |
while modification of a list element does not cause the modification |
| |
of the whole list object. |
| |
|
| |
By this, in @b{Asir} language, |
| |
a vector element designator can be a left value of |
| |
assignment statement, but a list element designator can NOT be a left |
| |
value of assignment statement. |
| |
|
| |
@item |
| |
No distinction of column vectors and row vectors in @b{Asir}. |
| |
If a matrix is applied to a vector from left, the vector shall be taken |
| |
as a column vector, and if from right it shall be taken as a row vector. |
| |
@item |
| |
The length (or size or dimension) of a vector is given by function |
| |
@code{size()}. |
| |
@item |
| |
When a vector is passed to a function as its argument |
| |
(actual parameter), the vector element can be modified in that |
| |
function. |
| |
|
| |
@item |
| |
A vector is displayed in a similar format as for a list. |
| |
Note, however, there is a distinction: Elements of a vector are |
| |
separated simply by a `blank space', while those of a list by a `comma.' |
| |
\E |
| @end itemize |
@end itemize |
| |
|
| @example |
@example |
|
|
| @end example |
@end example |
| |
|
| @table @t |
@table @t |
| @item $B;2>H(B |
\JP @item $B;2>H(B |
| @fref{newmat}, @fref{size}. |
\EG @item References |
| |
@fref{newmat}, @fref{size}, @fref{vtol}. |
| @end table |
@end table |
| |
|
| @node vtol,,, $BG[Ns(B |
\JP @node vtol,,, $BG[Ns(B |
| |
\EG @node vtol,,, Arrays |
| @subsection @code{vtol} |
@subsection @code{vtol} |
| @findex vtol |
@findex vtol |
| |
|
| @table @t |
@table @t |
| @item vtol(@var{vect}) |
@item vtol(@var{vect}) |
| :: $B%Y%/%H%k$r%j%9%H$KJQ49$9$k(B. |
\JP :: $B%Y%/%H%k$r%j%9%H$KJQ49$9$k(B. |
| |
\EG :: Converts a vector into a list. |
| @end table |
@end table |
| |
|
| @table @var |
@table @var |
| @item return |
@item return |
| $B%j%9%H(B |
\JP $B%j%9%H(B |
| |
\EG list |
| @item vect |
@item vect |
| $B%Y%/%H%k(B |
\JP $B%Y%/%H%k(B |
| |
\EG vector |
| @end table |
@end table |
| |
|
| @itemize @bullet |
@itemize @bullet |
| |
\BJP |
| @item |
@item |
| $BD9$5(B @var{n} $B$N%Y%/%H%k(B @var{vect} $B$r(B |
$BD9$5(B @var{n} $B$N%Y%/%H%k(B @var{vect} $B$r(B |
| @code{[@var{vect}[0],...,@var{vect}[@var{n}-1]]} $B$J$k%j%9%H$KJQ49$9$k(B. |
@code{[@var{vect}[0],...,@var{vect}[@var{n}-1]]} $B$J$k%j%9%H$KJQ49$9$k(B. |
| @item |
@item |
| $B%j%9%H$+$i%Y%/%H%k$X$NJQ49$O(B @code{newvect()} $B$G9T$&(B. |
$B%j%9%H$+$i%Y%/%H%k$X$NJQ49$O(B @code{newvect()} $B$G9T$&(B. |
| |
\E |
| |
\BEG |
| |
@item |
| |
Converts a vector @var{vect} of length @var{n} into |
| |
a list @code{[@var{vect}[0],...,@var{vect}[@var{n}-1]]}. |
| |
@item |
| |
A conversion from a list to a vector is done by @code{newvect()}. |
| |
\E |
| @end itemize |
@end itemize |
| |
|
| @example |
@example |
|
|
| @end example |
@end example |
| |
|
| @table @t |
@table @t |
| @item $B;2>H(B |
\JP @item $B;2>H(B |
| |
\EG @item References |
| @fref{newvect}. |
@fref{newvect}. |
| @end table |
@end table |
| |
|
| @node newmat,,, $BG[Ns(B |
\JP @node newmat,,, $BG[Ns(B |
| |
\EG @node newmat,,, Arrays |
| @subsection @code{newmat} |
@subsection @code{newmat} |
| @findex newmat |
@findex newmat |
| |
|
| @table @t |
@table @t |
| @item newmat(@var{row},@var{col} [,@var{[[a,b,}...@var{],[c,d,}...@var{],}...@var{]}]) |
@item newmat(@var{row},@var{col} [,@var{[[a,b,}...@var{],[c,d,}...@var{],}...@var{]}]) |
| :: @var{row} $B9T(B @var{col} $BNs$N9TNs$r@8@.$9$k(B. |
\JP :: @var{row} $B9T(B @var{col} $BNs$N9TNs$r@8@.$9$k(B. |
| |
\EG :: Creates a new matrix with @var{row} rows and @var{col} columns. |
| @end table |
@end table |
| |
|
| @table @var |
@table @var |
| @item return |
@item return |
| $B9TNs(B |
\JP $B9TNs(B |
| |
\EG matrix |
| @item row,col |
@item row,col |
| $B<+A3?t(B |
\JP $B<+A3?t(B |
| |
\EG non-negative integer |
| @item a,b,c,d |
@item a,b,c,d |
| $BG$0U(B |
\JP $BG$0U(B |
| |
\EG arbitrary |
| @end table |
@end table |
| |
|
| @itemize @bullet |
@itemize @bullet |
| |
\BJP |
| @item |
@item |
| @var{row} $B9T(B @var{col} $BNs$N9TNs$r@8@.$9$k(B. $BBh(B 3 $B0z?t$,$J$$>l9g(B, |
@var{row} $B9T(B @var{col} $BNs$N9TNs$r@8@.$9$k(B. $BBh(B 3 $B0z?t$,$J$$>l9g(B, |
| $B3F@.J,$O(B 0 $B$K=i4|2=$5$l$k(B. $BBh(B 3 $B0z?t$,$"$k>l9g(B, |
$B3F@.J,$O(B 0 $B$K=i4|2=$5$l$k(B. $BBh(B 3 $B0z?t$,$"$k>l9g(B, |
|
|
| @item |
@item |
| $BH!?t$N0z?t$H$7$F9TNs$rEO$7$?>l9g(B, $BEO$5$l$?H!?t$O(B, $B$=$N9TNs$N@.J,(B |
$BH!?t$N0z?t$H$7$F9TNs$rEO$7$?>l9g(B, $BEO$5$l$?H!?t$O(B, $B$=$N9TNs$N@.J,(B |
| $B$r=q$-49$($k$3$H$,$G$-$k(B. |
$B$r=q$-49$($k$3$H$,$G$-$k(B. |
| |
\E |
| |
\BEG |
| |
@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) |
| |
initializes each of the rows of the matrix. |
| |
Elements are used from the first through the last. |
| |
If the list is short, 0's are filled in the remaining matrix elements. |
| |
If no third argument is given all the elements are cleared to 0. |
| |
@item |
| |
The size of a matrix is given by function @code{size()}. |
| |
@item |
| |
Let @code{M} be a program variable assigned to a matrix. |
| |
Then, @code{M[I]} denotes a (row) vector which corresponds with |
| |
the @code{I}-th row of the matrix. |
| |
Note that the vector shares its element with the original matrix. |
| |
Subsequently, if an element of the vector is modified, then the |
| |
corresponding matrix element is also modified. |
| |
@item |
| |
When a matrix is passed to a function as its argument |
| |
(actual parameter), the matrix element can be modified within that |
| |
function. |
| |
\E |
| @end itemize |
@end itemize |
| |
|
| @example |
@example |
| Line 167 return to toplevel |
|
| Line 278 return to toplevel |
|
| @end example |
@end example |
| |
|
| @table @t |
@table @t |
| @item $B;2>H(B |
\JP @item $B;2>H(B |
| |
\EG @item References |
| @fref{newvect}, @fref{size}, @fref{det}. |
@fref{newvect}, @fref{size}, @fref{det}. |
| @end table |
@end table |
| |
|
| @node size,,, $BG[Ns(B |
\JP @node size,,, $BG[Ns(B |
| |
\EG @node size,,, Arrays |
| @subsection @code{size} |
@subsection @code{size} |
| @findex size |
@findex size |
| |
|
| @table @t |
@table @t |
| @item size(@var{vect|mat}) |
@item size(@var{vect|mat}) |
| :: @code{[@var{vect} $B$ND9$5(B]} $B$^$?$O(B @code{[@var{mat} $B$N9T?t(B,@var{mat} $B$NNs?t(B]}. |
\JP :: @code{[@var{vect} $B$ND9$5(B]} $B$^$?$O(B @code{[@var{mat} $B$N9T?t(B,@var{mat} $B$NNs?t(B]}. |
| |
\BEG |
| |
:: A list containing the number of elements of the given vector, |
| |
@code{[size of @var{vect}]}, |
| |
or a list containing row size and column size of the given matrix, |
| |
@code{[row size of @var{mat}, column size of @var{mat}]}. |
| |
\E |
| @end table |
@end table |
| |
|
| @table @var |
@table @var |
| @item return |
@item return |
| $B%j%9%H(B |
\JP $B%j%9%H(B |
| |
\EG list |
| @item vect |
@item vect |
| $B%Y%/%H%k(B |
\JP $B%Y%/%H%k(B |
| |
\EG vector |
| @item mat |
@item mat |
| $B9TNs(B |
\JP $B9TNs(B |
| |
\EG matrix |
| @end table |
@end table |
| |
|
| @itemize @bullet |
@itemize @bullet |
| |
\BJP |
| @item |
@item |
| @var{vect} $BKt$O(B, @var{mat} $B$N%5%$%:$r%j%9%H$G=PNO$9$k(B. |
@var{vect} $BKt$O(B, @var{mat} $B$N%5%$%:$r%j%9%H$G=PNO$9$k(B. |
| @item |
@item |
| @var{list} $B$N%5%$%:$O(B @code{length()}$B$r(B, $BM-M}<0$K8=$l$kC19`<0$N?t$O(B @code{nmono()} $B$rMQ$$$k(B. |
@var{list} $B$N%5%$%:$O(B @code{length()}$B$r(B, $BM-M}<0$K8=$l$kC19`<0$N?t$O(B @code{nmono()} $B$rMQ$$$k(B. |
| |
\E |
| |
\BEG |
| |
@item |
| |
Return a list consisting of the dimension of the vector @var{vect}, |
| |
or a list consisting of the row size and column size of the matrix |
| |
@var{matrix}. |
| |
@item |
| |
Use @code{length()} for the size of @var{list}, and |
| |
@code{nmono()} for the number of monomials with non-zero coefficients |
| |
in a rational expression. |
| |
\E |
| @end itemize |
@end itemize |
| |
|
| @example |
@example |
| Line 209 return to toplevel |
|
| Line 343 return to toplevel |
|
| @end example |
@end example |
| |
|
| @table @t |
@table @t |
| @item $B;2>H(B |
\JP @item $B;2>H(B |
| |
\EG @item References |
| @fref{car cdr cons append reverse length}, @fref{nmono}. |
@fref{car cdr cons append reverse length}, @fref{nmono}. |
| @end table |
@end table |
| |
|
| @node det,,, $BG[Ns(B |
\JP @node det,,, $BG[Ns(B |
| |
\EG @node det,,, Arrays |
| @subsection @code{det} |
@subsection @code{det} |
| @findex det |
@findex det |
| |
|
| @table @t |
@table @t |
| @item det(@var{mat}[,@var{mod}]) |
@item det(@var{mat}[,@var{mod}]) |
| :: @var{mat} $B$N9TNs<0$r5a$a$k(B. |
\JP :: @var{mat} $B$N9TNs<0$r5a$a$k(B. |
| |
\EG :: Determinant of @var{mat}. |
| @end table |
@end table |
| |
|
| @table @var |
@table @var |
| @item return |
@item return |
| $B<0(B |
\JP $B<0(B |
| |
\EG expression |
| @item mat |
@item mat |
| $B9TNs(B |
\JP $B9TNs(B |
| |
\EG matrix |
| @item mod |
@item mod |
| $BAG?t(B |
\JP $BAG?t(B |
| |
\EG prime |
| @end table |
@end table |
| |
|
| @itemize @bullet |
@itemize @bullet |
| |
\BJP |
| @item |
@item |
| $B9TNs(B @var{mat} $B$N9TNs<0$r5a$a$k(B. |
$B9TNs(B @var{mat} $B$N9TNs<0$r5a$a$k(B. |
| @item |
@item |
| Line 239 return to toplevel |
|
| Line 380 return to toplevel |
|
| @item |
@item |
| $BJ,?t$J$7$N%,%&%9>C5nK!$K$h$C$F$$$k$?$a(B, $BB?JQ?tB?9`<0$r@.J,$H$9$k(B |
$BJ,?t$J$7$N%,%&%9>C5nK!$K$h$C$F$$$k$?$a(B, $BB?JQ?tB?9`<0$r@.J,$H$9$k(B |
| $B9TNs$KBP$7$F$O>.9TNs<0E83+$K$h$kJ}K!$N$[$&$,8zN($,$h$$>l9g$b$"$k(B. |
$B9TNs$KBP$7$F$O>.9TNs<0E83+$K$h$kJ}K!$N$[$&$,8zN($,$h$$>l9g$b$"$k(B. |
| |
\E |
| |
\BEG |
| |
@item |
| |
Determinant of matrix @var{mat}. |
| |
@item |
| |
The computation is done over GF(@var{mod}) if @var{mod} is specitied. |
| |
@item |
| |
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. |
| |
\E |
| @end itemize |
@end itemize |
| |
|
| @example |
@example |
| Line 258 return to toplevel |
|
| Line 410 return to toplevel |
|
| @end example |
@end example |
| |
|
| @table @t |
@table @t |
| @item $B;2>H(B |
\JP @item $B;2>H(B |
| |
\EG @item References |
| @fref{newmat}. |
@fref{newmat}. |
| @end table |
@end table |
| |
|
| @node qsort,,, $BG[Ns(B |
\JP @node qsort,,, $BG[Ns(B |
| |
\EG @node qsort,,, Arrays |
| @subsection @code{qsort} |
@subsection @code{qsort} |
| @findex qsort |
@findex qsort |
| |
|
| @table @t |
@table @t |
| @item qsort(@var{array}[,@var{func}]) |
@item qsort(@var{array}[,@var{func}]) |
| :: $B0l<!85G[Ns(B @var{array} $B$r%=!<%H$9$k(B. |
\JP :: $B0l<!85G[Ns(B @var{array} $B$r%=!<%H$9$k(B. |
| |
\EG :: Sorts an array @var{array}. |
| @end table |
@end table |
| |
|
| @table @var |
@table @var |
| @item return |
@item return |
| @var{array} ($BF~NO$HF1$8(B; $BMWAG$N$_F~$lBX$o$k(B) |
\JP @var{array} ($BF~NO$HF1$8(B; $BMWAG$N$_F~$lBX$o$k(B) |
| |
\EG @var{array} (The same as the input; Only the elements are exchanged.) |
| @item array |
@item array |
| $B0l<!85G[Ns(B |
\JP $B0l<!85G[Ns(B |
| |
\EG array |
| @item func |
@item func |
| $BHf3SMQ4X?t(B |
\JP $BHf3SMQ4X?t(B |
| |
\EG function for comparison |
| @end table |
@end table |
| |
|
| @itemize @bullet |
@itemize @bullet |
| |
\BJP |
| @item |
@item |
| $B0l<!85G[Ns$r(B quick sort $B$G%=!<%H$9$k(B. |
$B0l<!85G[Ns$r(B quick sort $B$G%=!<%H$9$k(B. |
| @item |
@item |
| Line 292 return to toplevel |
|
| Line 451 return to toplevel |
|
| $B$b$N$+$i=g$KJB$Y49$($i$l$k(B. |
$B$b$N$+$i=g$KJB$Y49$($i$l$k(B. |
| @item |
@item |
| $BG[Ns$O?7$?$K@8@.$5$l$:(B, $B0z?t$NG[Ns$NMWAG$N$_F~$lBX$o$k(B. |
$BG[Ns$O?7$?$K@8@.$5$l$:(B, $B0z?t$NG[Ns$NMWAG$N$_F~$lBX$o$k(B. |
| |
\E |
| |
\BEG |
| |
@item |
| |
This function sorts an array by @var{quick sort}. |
| |
@item |
| |
If @var{func} is not specified, the built-in comparison function |
| |
is used and the array is sorted in increasing order. |
| |
@item |
| |
If a function of two arguments @var{func} which returns 0, 1, or -1 |
| |
is provided, then an ordering is detemined so that |
| |
@code{A<B} if @code{@var{func}(A,B)=1} holds, and |
| |
the array is sorted in increasing order with respect to the ordering. |
| |
@item |
| |
The returned array is the same as the input. Only the elements |
| |
are exchanged. |
| |
\E |
| @end itemize |
@end itemize |
| |
|
| @example |
@example |
| Line 303 return to toplevel |
|
| Line 478 return to toplevel |
|
| @end example |
@end example |
| |
|
| @table @t |
@table @t |
| @item $B;2>H(B |
\JP @item $B;2>H(B |
| |
\EG @item References |
| @fref{ord}, @fref{vars}. |
@fref{ord}, @fref{vars}. |
| @end table |
@end table |