[BACK]Return to array.texi CVS log [TXT][DIR] Up to [local] / OpenXM / src / asir-doc / parts / builtin

Annotation of OpenXM/src/asir-doc/parts/builtin/array.texi, Revision 1.1.1.1

1.1       noro        1: @node $BG[Ns(B,,, $BAH$_9~$_H!?t(B
                      2: @section $BG[Ns(B
                      3:
                      4: @menu
                      5: * newvect::
                      6: * vtol::
                      7: * newmat::
                      8: * size::
                      9: * det::
                     10: * qsort::
                     11: @end menu
                     12:
                     13: @node newvect,,, $BG[Ns(B
                     14: @subsection @code{newvect}
                     15: @findex newvect
                     16:
                     17: @table @t
                     18: @item newvect(@var{len}[,@var{list}])
                     19: :: $BD9$5(B @var{len} $B$N%Y%/%H%k$r@8@.$9$k(B.
                     20: @end table
                     21:
                     22: @table @var
                     23: @item return
                     24: $B%Y%/%H%k(B
                     25: @item len
                     26: $B<+A3?t(B
                     27: @item list
                     28: $B%j%9%H(B
                     29: @end table
                     30:
                     31: @itemize @bullet
                     32: @item
                     33: $BD9$5(B @var{len} $B$N%Y%/%H%k$r@8@.$9$k(B. $BBh(B 2 $B0z?t$,$J$$>l9g(B,
                     34: $B3F@.J,$O(B 0 $B$K=i4|2=$5$l$k(B. $BBh(B 2 $B0z?t$,$"$k>l9g(B,
                     35: $B%$%s%G%C%/%9$N>.$5$$@.J,$+$i(B, $B%j%9%H$N(B
                     36: $B3FMWAG$K$h$j=i4|2=$5$l$k(B. $B3FMWAG$O(B, $B@hF,$+$i=g$K(B
                     37: $B;H$o$l(B, $BB-$j$J$$J,$O(B 0 $B$,Kd$a$i$l$k(B.
                     38: @item
                     39: $B%Y%/%H%k$N@.J,$O(B, $BBh(B 0 $B@.J,$+$iBh(B @var{len}-1 $B@.J,$H$J$k(B.
                     40: ($BBh(B 1 $B@.J,$+$i$G$O$J$$;v$KCm0U(B. )
                     41: @item
                     42: $B%j%9%H$O3F@.J,$,(B, $B%]%$%s%?$rC)$k;v$K$h$C$F%7!<%1%s%7%c%k$K(B
                     43: $B8F$S=P$5$l$k$N$KBP$7(B, $B%Y%/%H%k$O3F@.J,$,(B
                     44: $BBh0l@.J,$+$i$N%a%b%j>e$N(B displacement ($BJQ0L(B)$B$K$h$C$F%i%s%@%`%"%/%;%9$G(B
                     45: $B8F$S=P$5$l(B, $B$=$N7k2L(B, $B@.J,$N%"%/%;%9;~4V$KBg$-$J:9$,=P$F$/$k(B.
                     46: $B@.J,%"%/%;%9$O(B, $B%j%9%H$G$O(B, $B@.J,$NNL$,A}$($k$K=>$C$F(B
                     47: $B;~4V$,$+$+$k$h$&$K$J$k$,(B, $B%Y%/%H%k$G$O(B, $B@.J,$NNL$K0MB8$;$:$[$\0lDj$G$"$k(B.
                     48: @item
                     49: @b{Asir} $B$G$O(B, $B=D%Y%/%H%k(B, $B2#%Y%/%H%k$N6hJL$O$J$$(B.
                     50: $B9TNs$r:8$+$i3]$1$l$P=D%Y%/%H%k$H$_$J$5$l$k$7(B, $B1&$+$i3]$1$l$P2#%Y%/%H%k$H(B
                     51: $B$_$J$5$l$k(B.
                     52: @item
                     53: $B%Y%/%H%k$ND9$5$O(B @code{size()} $B$K$h$C$FF@$i$l$k(B.
                     54: @item
                     55: $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
                     56: $B$r=q$-49$($k$3$H$,$G$-$k(B.
                     57: @end itemize
                     58:
                     59: @example
                     60: [0] A=newvect(5);
                     61: [ 0 0 0 0 0 ]
                     62: [1] A=newvect(5,[1,2,3,4,[5,6]]);
                     63: [ 1 2 3 4 [5,6] ]
                     64: [2] A[0];
                     65: 1
                     66: [3] A[4];
                     67: [5,6]
                     68: [4] size(A);
                     69: [5]
                     70: [5] def afo(V) @{ V[0] = x; @}
                     71: [6] afo(A)$
                     72: [7] A;
                     73: [ x 2 3 4 [5,6] ]
                     74: @end example
                     75:
                     76: @table @t
                     77: @item $B;2>H(B
                     78: @fref{newmat}, @fref{size}.
                     79: @end table
                     80:
                     81: @node vtol,,, $BG[Ns(B
                     82: @subsection @code{vtol}
                     83: @findex vtol
                     84:
                     85: @table @t
                     86: @item vtol(@var{vect})
                     87: :: $B%Y%/%H%k$r%j%9%H$KJQ49$9$k(B.
                     88: @end table
                     89:
                     90: @table @var
                     91: @item return
                     92: $B%j%9%H(B
                     93: @item vect
                     94: $B%Y%/%H%k(B
                     95: @end table
                     96:
                     97: @itemize @bullet
                     98: @item
                     99: $BD9$5(B @var{n} $B$N%Y%/%H%k(B @var{vect} $B$r(B
                    100:  @code{[@var{vect}[0],...,@var{vect}[@var{n}-1]]} $B$J$k%j%9%H$KJQ49$9$k(B.
                    101: @item
                    102: $B%j%9%H$+$i%Y%/%H%k$X$NJQ49$O(B @code{newvect()} $B$G9T$&(B.
                    103: @end itemize
                    104:
                    105: @example
                    106: [3] A=newvect(3,[1,2,3]);
                    107: [ 1 2 3 ]
                    108: [4] vtol(A);
                    109: [1,2,3]
                    110: @end example
                    111:
                    112: @table @t
                    113: @item $B;2>H(B
                    114: @fref{newvect}.
                    115: @end table
                    116:
                    117: @node newmat,,, $BG[Ns(B
                    118: @subsection @code{newmat}
                    119: @findex newmat
                    120:
                    121: @table @t
                    122: @item newmat(@var{row},@var{col} [,@var{[[a,b,}...@var{],[c,d,}...@var{],}...@var{]}])
                    123: :: @var{row} $B9T(B @var{col} $BNs$N9TNs$r@8@.$9$k(B.
                    124: @end table
                    125:
                    126: @table @var
                    127: @item return
                    128: $B9TNs(B
                    129: @item row,col
                    130: $B<+A3?t(B
                    131: @item a,b,c,d
                    132: $BG$0U(B
                    133: @end table
                    134:
                    135: @itemize @bullet
                    136: @item
                    137: @var{row} $B9T(B @var{col} $BNs$N9TNs$r@8@.$9$k(B. $BBh(B 3 $B0z?t$,$J$$>l9g(B,
                    138: $B3F@.J,$O(B 0 $B$K=i4|2=$5$l$k(B. $BBh(B 3 $B0z?t$,$"$k>l9g(B,
                    139: $B%$%s%G%C%/%9$N>.$5$$@.J,$+$i(B, $B3F9T$,(B, $B%j%9%H$N(B
                    140: $B3FMWAG(B ($B$3$l$O$^$?%j%9%H$G$"$k(B) $B$K$h$j=i4|2=$5$l$k(B. $B3FMWAG$O(B, $B@hF,$+$i=g$K(B
                    141: $B;H$o$l(B, $BB-$j$J$$J,$O(B 0 $B$,Kd$a$i$l$k(B.
                    142: @item
                    143: $B9TNs$N%5%$%:$O(B @code{size()} $B$GF@$i$l$k(B.
                    144: @item
                    145: @code{M} $B$,9TNs$N$H$-(B, @code{M[I]} $B$K$h$jBh(B @code{I} $B9T$r%Y%/%H%k$H$7$F(B
                    146: $B<h$j=P$9$3$H$,$G$-$k(B. $B$3$N%Y%/%H%k$O(B, $B$b$H$N9TNs$H@.J,$r6&M-$7$F$*$j(B,
                    147: $B$$$:$l$+$N@.J,$r=q$-49$($l$P(B, $BB>$NBP1~$9$k@.J,$b=q$-49$o$k$3$H$K$J$k(B.
                    148: @item
                    149: $BH!?t$N0z?t$H$7$F9TNs$rEO$7$?>l9g(B, $BEO$5$l$?H!?t$O(B, $B$=$N9TNs$N@.J,(B
                    150: $B$r=q$-49$($k$3$H$,$G$-$k(B.
                    151: @end itemize
                    152:
                    153: @example
                    154: [0] A = newmat(3,3,[[1,1,1],[x,y],[x^2]]);
                    155: [ 1 1 1 ]
                    156: [ x y 0 ]
                    157: [ x^2 0 0 ]
                    158: [1] det(A);
                    159: -y*x^2
                    160: [2] size(A);
                    161: [3,3]
                    162: [3] A[1];
                    163: [ x y 0 ]
                    164: [4] A[1][3];
                    165: getarray : Out of range
                    166: return to toplevel
                    167: @end example
                    168:
                    169: @table @t
                    170: @item $B;2>H(B
                    171: @fref{newvect}, @fref{size}, @fref{det}.
                    172: @end table
                    173:
                    174: @node size,,, $BG[Ns(B
                    175: @subsection @code{size}
                    176: @findex size
                    177:
                    178: @table @t
                    179: @item size(@var{vect|mat})
                    180: :: @code{[@var{vect} $B$ND9$5(B]} $B$^$?$O(B @code{[@var{mat} $B$N9T?t(B,@var{mat} $B$NNs?t(B]}.
                    181: @end table
                    182:
                    183: @table @var
                    184: @item return
                    185: $B%j%9%H(B
                    186: @item vect
                    187: $B%Y%/%H%k(B
                    188: @item mat
                    189: $B9TNs(B
                    190: @end table
                    191:
                    192: @itemize @bullet
                    193: @item
                    194: @var{vect} $BKt$O(B, @var{mat} $B$N%5%$%:$r%j%9%H$G=PNO$9$k(B.
                    195: @item
                    196: @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.
                    197: @end itemize
                    198:
                    199: @example
                    200: [0] A = newvect(4);
                    201: [ 0 0 0 0 ]
                    202: [1] size(A);
                    203: [4]
                    204: [2] B = newmat(2,3,[[1,2,3],[4,5,6]]);
                    205: [ 1 2 3 ]
                    206: [ 4 5 6 ]
                    207: [3] size(B);
                    208: [2,3]
                    209: @end example
                    210:
                    211: @table @t
                    212: @item $B;2>H(B
                    213: @fref{car cdr cons append reverse length}, @fref{nmono}.
                    214: @end table
                    215:
                    216: @node det,,, $BG[Ns(B
                    217: @subsection @code{det}
                    218: @findex det
                    219:
                    220: @table @t
                    221: @item det(@var{mat}[,@var{mod}])
                    222: :: @var{mat} $B$N9TNs<0$r5a$a$k(B.
                    223: @end table
                    224:
                    225: @table @var
                    226: @item return
                    227: $B<0(B
                    228: @item mat
                    229: $B9TNs(B
                    230: @item mod
                    231: $BAG?t(B
                    232: @end table
                    233:
                    234: @itemize @bullet
                    235: @item
                    236: $B9TNs(B @var{mat} $B$N9TNs<0$r5a$a$k(B.
                    237: @item
                    238: $B0z?t(B @var{mod} $B$,$"$k;~(B, GF(@var{mod}) $B>e$G$N9TNs<0$r5a$a$k(B.
                    239: @item
                    240: $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
                    241: $B9TNs$KBP$7$F$O>.9TNs<0E83+$K$h$kJ}K!$N$[$&$,8zN($,$h$$>l9g$b$"$k(B.
                    242: @end itemize
                    243:
                    244: @example
                    245: [91] A=newmat(5,5)$
                    246: [92] V=[x,y,z,u,v];
                    247: [x,y,z,u,v]
                    248: [93] for(I=0;I<5;I++)for(J=0,B=A[I],W=V[I];J<5;J++)B[J]=W^J;
                    249: [94] A;
                    250: [ 1 x x^2 x^3 x^4 ]
                    251: [ 1 y y^2 y^3 y^4 ]
                    252: [ 1 z z^2 z^3 z^4 ]
                    253: [ 1 u u^2 u^3 u^4 ]
                    254: [ 1 v v^2 v^3 v^4 ]
                    255: [95] fctr(det(A));
                    256: [[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],
                    257: [-x+v,1],[-x+y,1]]
                    258: @end example
                    259:
                    260: @table @t
                    261: @item $B;2>H(B
                    262: @fref{newmat}.
                    263: @end table
                    264:
                    265: @node qsort,,, $BG[Ns(B
                    266: @subsection @code{qsort}
                    267: @findex qsort
                    268:
                    269: @table @t
                    270: @item qsort(@var{array}[,@var{func}])
                    271: :: $B0l<!85G[Ns(B @var{array} $B$r%=!<%H$9$k(B.
                    272: @end table
                    273:
                    274: @table @var
                    275: @item return
                    276: @var{array} ($BF~NO$HF1$8(B; $BMWAG$N$_F~$lBX$o$k(B)
                    277: @item array
                    278: $B0l<!85G[Ns(B
                    279: @item func
                    280: $BHf3SMQ4X?t(B
                    281: @end table
                    282:
                    283: @itemize @bullet
                    284: @item
                    285: $B0l<!85G[Ns$r(B quick sort $B$G%=!<%H$9$k(B.
                    286: @item
                    287: $BHf3SMQ4X?t$,;XDj$5$l$F$$$J$$>l9g(B, $B%*%V%8%'%/%H$I$&$7$NHf3S7k2L$G(B
                    288: $B=g=x$,2<$N$b$N$+$i=g$KJB$Y49$($i$l$k(B.
                    289: @item
                    290: 0, 1, -1 $B$rJV$9(B 2 $B0z?t4X?t$,(B @var{func} $B$H$7$FM?$($i$l$?>l9g(B,
                    291: @code{@var{func}(A,B)=1} $B$N>l9g$K(B @code{A<B} $B$H$7$F(B, $B=g=x$,2<$N(B
                    292: $B$b$N$+$i=g$KJB$Y49$($i$l$k(B.
                    293: @item
                    294: $BG[Ns$O?7$?$K@8@.$5$l$:(B, $B0z?t$NG[Ns$NMWAG$N$_F~$lBX$o$k(B.
                    295: @end itemize
                    296:
                    297: @example
                    298: [0] qsort(newvect(10,[1,4,6,7,3,2,9,6,0,-1]));
                    299: [ -1 0 1 2 3 4 6 6 7 9 ]
                    300: [1] def rev(A,B) @{ return A>B?-1:(A<B?1:0); @}
                    301: [2] qsort(newvect(10,[1,4,6,7,3,2,9,6,0,-1]),rev);
                    302: [ 9 7 6 6 4 3 2 1 0 -1 ]
                    303: @end example
                    304:
                    305: @table @t
                    306: @item $B;2>H(B
                    307: @fref{ord}, @fref{vars}.
                    308: @end table

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>