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

Annotation of OpenXM/src/asir-doc/parts/builtin/num.texi, Revision 1.10

1.10    ! ohara       1: @comment $OpenXM: OpenXM/src/asir-doc/parts/builtin/num.texi,v 1.9 2003/12/18 10:26:20 ohara Exp $
1.2       noro        2: \BJP
1.1       noro        3: @node $B?t$N1i;;(B,,, $BAH$_9~$_H!?t(B
                      4: @section $B?t$N1i;;(B
1.2       noro        5: \E
                      6: \BEG
                      7: @node Numbers,,, Built-in Function
                      8: @section Numbers
                      9: \E
1.1       noro       10:
                     11: @menu
                     12: * idiv irem::
                     13: * fac::
                     14: * igcd igcdcntl::
                     15: * ilcm::
1.10    ! ohara      16: * isqrt::
1.1       noro       17: * inv::
                     18: * prime lprime::
                     19: * random::
                     20: * mt_save mt_load::
                     21: * nm dn::
                     22: * conj real imag::
1.4       noro       23: * eval deval::
1.1       noro       24: * pari::
                     25: * setprec::
                     26: * setmod::
                     27: * lrandom::
1.3       noro       28: * ntoint32 int32ton::
1.1       noro       29: @end menu
                     30:
1.2       noro       31: \JP @node idiv irem,,, $B?t$N1i;;(B
                     32: \EG @node idiv irem,,, Numbers
1.1       noro       33: @subsection @code{idiv}, @code{irem}
                     34: @findex idiv
                     35: @findex irem
                     36:
                     37: @table @t
                     38: @item idiv(@var{i1},@var{i2})
1.2       noro       39: \JP :: $B@0?t=|;;$K$h$k>&(B.
                     40: \EG :: Integer quotient of @var{i1} divided by @var{i2}.
1.1       noro       41: @item irem(@var{i1},@var{i2})
1.2       noro       42: \JP :: $B@0?t=|;;$K$h$k>jM>(B.
                     43: \EG :: Integer remainder of @var{i1} divided by @var{i2}.
1.1       noro       44: @end table
                     45:
                     46: @table @var
                     47: @item return
1.2       noro       48: \JP $B@0?t(B
                     49: \EG integer
1.8       noro       50: @item i1 i2
1.2       noro       51: \JP $B@0?t(B
                     52: \EG integer
1.1       noro       53: @end table
                     54:
                     55: @itemize @bullet
1.2       noro       56: \BJP
1.1       noro       57: @item
                     58: @var{i1} $B$N(B @var{i2} $B$K$h$k@0?t=|;;$K$h$k>&(B, $B>jM>$r5a$a$k(B.
                     59: @item
                     60: @var{i2} $B$O(B 0 $B$G$"$C$F$O$J$i$J$$(B.
                     61: @item
                     62: $BHo=|?t$,Ii$N>l9g(B, $B@dBPCM$KBP$9$kCM$K%^%$%J%9$r$D$1$?CM$rJV$9(B.
                     63: @item
                     64: @var{i1} @code{%} @var{i2} $B$O(B, $B7k2L$,@5$K@55,2=$5$l$k$3$H$r=|$1$P(B
                     65: @code{irem()} $B$NBe$o$j$KMQ$$$k$3$H$,$G$-$k(B.
                     66: @item
                     67: $BB?9`<0$N>l9g$O(B @code{sdiv}, @code{srem} $B$rMQ$$$k(B.
1.2       noro       68: \E
                     69: \BEG
                     70: @item
                     71: Integer quotient and remainder of @var{i1} divided by @var{i2}.
                     72: @item
                     73: @var{i2} must not be 0.
                     74: @item
                     75: If the dividend is negative, the results are obtained by changing the
                     76: sign of the results for absolute values of the dividend.
                     77: @item
                     78: One can use
                     79: @var{i1} @code{%} @var{i2}
                     80: for replacement of @code{irem()} which only differs in the point that
                     81: the result is always normalized to non-negative values.
                     82: @item
                     83: Use @code{sdiv()}, @code{srem()} for polynomial quotient.
                     84: \E
1.1       noro       85: @end itemize
                     86:
                     87: @example
                     88: [0] idiv(100,7);
                     89: 14
                     90: [0] idiv(-100,7);
                     91: -14
                     92: [1] irem(100,7);
                     93: 2
                     94: [1] irem(-100,7);
                     95: -2
                     96: @end example
                     97:
                     98: @table @t
1.2       noro       99: \JP @item $B;2>H(B
                    100: \EG @item References
1.1       noro      101: @fref{sdiv sdivm srem sremm sqr sqrm}, @fref{%}.
                    102: @end table
                    103:
1.2       noro      104: \JP @node fac,,, $B?t$N1i;;(B
                    105: \EG @node fac,,, Numbers
1.1       noro      106: @subsection @code{fac}
                    107: @findex fac
                    108:
                    109: @table @t
                    110: @item fac(@var{i})
1.2       noro      111: \JP :: @var{i} $B$N3,>h(B.
                    112: \EG :: The factorial of @var{i}.
1.1       noro      113: @end table
                    114:
                    115: @table @var
                    116: @item return
1.2       noro      117: \JP $B@0?t(B
                    118: \EG integer
1.1       noro      119: @item i
1.2       noro      120: \JP $B@0?t(B
                    121: \EG integer
1.1       noro      122: @end table
                    123:
                    124: @itemize @bullet
1.2       noro      125: \BJP
1.1       noro      126: @item
                    127: @var{i} $B$N3,>h$r7W;;$9$k(B.
                    128: @item
                    129: @var{i} $B$,Ii$N>l9g$O(B 0 $B$rJV$9(B.
1.2       noro      130: \E
                    131: \BEG
                    132: @item
                    133: The factorial of @var{i}.
                    134: @item
                    135: Returns 0 if the argument @var{i} is negative.
                    136: \E
1.1       noro      137: @end itemize
                    138:
                    139: @example
                    140: [0] fac(50);
                    141: 30414093201713378043612608166064768844377641568960512000000000000
                    142: @end example
                    143:
1.2       noro      144: \JP @node igcd igcdcntl,,, $B?t$N1i;;(B
                    145: \EG @node igcd igcdcntl,,, Numbers
1.1       noro      146: @subsection @code{igcd},@code{igcdcntl}
                    147: @findex igcd
                    148: @findex igcdcntl
                    149:
                    150: @table @t
                    151: @item igcd(@var{i1},@var{i2})
1.2       noro      152: \JP :: $B@0?t$N(B GCD ($B:GBg8xLs?t(B)
                    153: \EG :: The integer greatest common divisor of @var{i1} and @var{i2}.
1.1       noro      154: @item igcdcntl([@var{i}])
1.2       noro      155: \JP :: $B@0?t(B GCD$B$N%"%k%4%j%:%`A*Br(B
                    156: \EG :: Selects an algorithm for integer GCD.
1.1       noro      157: @end table
                    158:
                    159: @table @var
                    160: @item return
1.2       noro      161: \JP $B@0?t(B
                    162: \EG integer
1.8       noro      163: @item i1 i2 i
1.2       noro      164: \JP $B@0?t(B
                    165: \EG integer
1.1       noro      166: @end table
                    167:
                    168: @itemize @bullet
1.2       noro      169: \BJP
1.1       noro      170: @item
                    171: @code{igcd} $B$O(B @var{i1} $B$H(B @var{i2} $B$N(B GCD $B$r5a$a$k(B.
                    172: @item
                    173: $B0z?t$,@0?t$G$J$$>l9g$O(B, $B%(%i!<$^$?$OL50UL#$J7k2L$rJV$9(B.
                    174: @item
                    175: $BB?9`<0$N>l9g$O(B, @code{gcd}, @code{gcdz} $B$rMQ$$$k(B.
                    176: @item
                    177: $B@0?t(B GCD $B$K$O$5$^$6$^$JJ}K!$,$"$j(B, @code{igcdcntl} $B$G@_Dj$G$-$k(B.
                    178:
                    179: @table @code
                    180: @item 0
                    181: Euclid $B8_=|K!(B (default)
                    182: @item 1
                    183: binary GCD
                    184: @item 2
                    185: bmod GCD
                    186: @item 3
                    187: accelerated integer GCD
                    188: @end table
1.2       noro      189: @code{2}, @code{3} $B$O(B @code{[Weber]} $B$K$h$k(B.
1.1       noro      190:
1.2       noro      191: $B$*$*$`$M(B @code{3} $B$,9bB.$@$,(B, $BNc30$b$"$k(B.
                    192: \E
                    193: \BEG
                    194: @item
                    195: Function @code{igcd()} returns the integer greatest common divisor of
                    196: the given two integers.
                    197: @item
                    198: An error will result if the argument is not an integer; the result is
                    199: not valid even if one is returned.
                    200: @item
                    201: Use @code{gcd()}, @code{gcdz()} for polynomial GCD.
                    202:
                    203: @item
                    204: Various method of integer GCD computation are implemented
                    205: and they can be selected by @code{igcdcntl}.
                    206:
                    207: @table @code
                    208: @item 0
                    209: Euclid algorithm (default)
                    210: @item 1
                    211: binary GCD
                    212: @item 2
                    213: bmod GCD
                    214: @item 3
                    215: accelerated integer GCD
                    216: @end table
                    217: @code{2}, @code{3} are due to @code{[Weber]}.
                    218:
                    219: In most cases @code{3} is the fastest, but there are exceptions.
                    220: \E
1.1       noro      221: @end itemize
                    222:
                    223: @example
                    224: [0] A=lrandom(10^4)$
                    225: [1] B=lrandom(10^4)$
                    226: [2] C=lrandom(10^4)$
                    227: [3] D=A*C$
                    228: [4] E=A*B$
                    229: [5] cputime(1)$
                    230: [6] igcd(D,E)$
                    231: 0.6sec + gc : 1.93sec(2.531sec)
                    232: [7] igcdcntl(1)$
                    233: [8] igcd(D,E)$
                    234: 0.27sec(0.2635sec)
                    235: [9] igcdcntl(2)$
                    236: [10] igcd(D,E)$
                    237: 0.19sec(0.1928sec)
                    238: [11] igcdcntl(3)$
                    239: [12] igcd(D,E)$
                    240: 0.08sec(0.08023sec)
                    241: @end example
                    242:
                    243: @table @t
1.2       noro      244: \JP @item $B;2>H(B
                    245: \EG @item References
1.1       noro      246: @fref{gcd gcdz}.
                    247: @end table
                    248:
1.2       noro      249: \JP @node ilcm,,, $B?t$N1i;;(B
                    250: \EG @node ilcm,,, Numbers
1.1       noro      251: @subsection @code{ilcm}
                    252: @findex ilcm
                    253:
                    254: @table @t
                    255: @item ilcm(@var{i1},@var{i2})
1.2       noro      256: \JP :: $B:G>.8xG\?t$r5a$a$k(B.
                    257: \EG :: The integer least common multiple of @var{i1} and @var{i2}.
1.1       noro      258: @end table
                    259:
                    260: @table @var
                    261: @item return
1.2       noro      262: \JP $B@0?t(B
                    263: \EG integer
1.8       noro      264: @item i1 i2
1.2       noro      265: \JP $B@0?t(B
                    266: \EG integer
1.1       noro      267: @end table
                    268:
                    269: @itemize @bullet
1.2       noro      270: \BJP
1.1       noro      271: @item
                    272: $B@0?t(B @var{i1}, @var{i2} $B$N:G>.8xG\?t$r5a$a$k(B.
                    273: @item
                    274: $B0lJ}$,(B 0 $B$N>l9g(B 0 $B$rJV$9(B.
1.2       noro      275: \E
                    276: \BEG
1.1       noro      277: @item
1.2       noro      278: This function computes the integer least common multiple of
                    279: @var{i1}, @var{i2}.
                    280: @item
                    281: If one of argument is equal to 0, the return 0.
                    282: \E
1.1       noro      283: @end itemize
                    284:
                    285: @table @t
1.2       noro      286: \JP @item $B;2>H(B
                    287: \EG @item References
1.1       noro      288: @fref{igcd igcdcntl}, @fref{mt_save mt_load}.
1.9       ohara     289: @end table
                    290:
                    291: \JP @node isqrt,,, $B?t$N1i;;(B
                    292: \EG @node isqrt,,, Numbers
                    293: @subsection @code{isqrt}
                    294: @findex isqrt
                    295:
                    296: @table @t
                    297: @item isqrt(@var{n})
                    298: \JP :: $BJ?J}:,$r1[$($J$$:GBg$N@0?t$r5a$a$k(B.
                    299: \EG :: The integer square root of @var{n}.
                    300: @end table
                    301:
                    302: @table @var
                    303: @item return
                    304: \JP $BHsIi@0?t(B
                    305: \EG non-negative integer
                    306: @item n
                    307: \JP $BHsIi@0?t(B
                    308: \EG non-negative integer
1.1       noro      309: @end table
1.2       noro      310:
                    311: \JP @node inv,,, $B?t$N1i;;(B
                    312: \EG @node inv,,, Numbers
1.1       noro      313: @subsection @code{inv}
                    314: @findex inv
                    315:
                    316: @table @t
                    317: @item inv(@var{i},@var{m})
1.2       noro      318: \JP :: @var{m} $B$rK!$H$9$k(B @var{i} $B$N5U?t(B
                    319: \EG :: the inverse (reciprocal) of @var{i} modulo @var{m}.
1.1       noro      320: @end table
                    321:
                    322: @table @var
                    323: @item return
1.2       noro      324: \JP $B@0?t(B
                    325: \EG integer
1.8       noro      326: @item i m
1.2       noro      327: \JP $B@0?t(B
                    328: \EG integer
1.1       noro      329: @end table
                    330:
                    331: @itemize @bullet
1.2       noro      332: \BJP
1.1       noro      333: @item
                    334: @var{ia} @equiv{} 1 mod (@var{m}) $B$J$k@0?t(B @var{a} $B$r5a$a$k(B.
                    335: @item
                    336: @var{i} $B$H(B @var{m} $B$O8_$$$KAG$G$J$1$l$P$J$i$J$$$,(B, @code{inv()} $B$O(B
                    337: $B$=$N%A%'%C%/$O9T$o$J$$(B.
1.2       noro      338: \E
                    339: \BEG
                    340: @item
                    341: This function computes an integer such that
                    342: @var{ia} @equiv{} 1 mod (@var{m}).
                    343: @item
                    344: The integer @var{i} and  @var{m} must be mutually prime.
                    345: However, @code{inv()} does not check it.
                    346: \E
1.1       noro      347: @end itemize
                    348:
                    349: @example
                    350: [71] igcd(1234,4321);
                    351: 1
                    352: [72] inv(1234,4321);
                    353: 3239
                    354: [73] irem(3239*1234,4321);
                    355: 1
                    356: @end example
                    357:
                    358: @table @t
1.2       noro      359: \JP @item $B;2>H(B
                    360: \EG @item References
1.1       noro      361: @fref{igcd igcdcntl}.
                    362: @end table
                    363:
1.2       noro      364: \JP @node prime lprime,,, $B?t$N1i;;(B
                    365: \EG @node prime lprime,,, Numbers
1.1       noro      366: @subsection @code{prime}, @code{lprime}
                    367: @findex prime
                    368: @findex lprime
                    369:
                    370: @table @t
                    371: @item prime(@var{index})
                    372: @item lprime(@var{index})
1.2       noro      373: \JP :: $BAG?t$rJV$9(B
                    374: \EG :: Returns a prime number.
1.1       noro      375: @end table
                    376:
                    377: @table @var
                    378: @item return
1.2       noro      379: \JP $B@0?t(B
                    380: \EG integer
1.1       noro      381: @item index
1.2       noro      382: \JP $B@0?t(B
                    383: \EG integer
1.1       noro      384: @end table
                    385:
                    386: @itemize @bullet
1.2       noro      387: \BJP
1.1       noro      388: @item
                    389: @code{prime()}, @code{lprime()} $B$$$:$l$b%7%9%F%`$,FbIt$K;}$D(B
                    390: $BAG?tI=$NMWAG$rJV$9(B. @code{index} $B$O(B 0 $B0J>e$N@0?t$G(B, $BAG?tI=(B
                    391: $B$N%$%s%G%C%/%9$KMQ$$$i$l$k(B. @code{prime()} $B$O(B 16381 $B$^$G(B
                    392: $B$NAG?t$r>.$5$$=g$K(B 1900 $B8D(B, @code{lprime()} $B$O(B, 10 $B?J(B 8 $B7e$G:GBg$N(B
                    393: $BAG?t$+$iBg$-$$=g$K(B 999 $B8DJV$9(B. $B$=$l0J30$N%$%s%G%C%/%9$KBP$7$F$O(B
                    394: 0 $B$rJV$9(B.
                    395: @item
1.2       noro      396: $B$h$j0lHLE*$JAG?t@8@.H!?t$H$7$F$O(B,
                    397: @code{pari(nextprime,@var{number})}
1.1       noro      398: $B$,$"$k(B.
1.2       noro      399: \E
                    400: \BEG
                    401: @item
                    402: The two functions, @code{prime()} and @code{lprime()}, returns
                    403: an element stored in the system table of prime numbers.
                    404: Here, @code{index} is a non-negative integer and be used as an index
                    405: for the prime tables.
                    406: The function @code{prime()} can return one of 1900 primes
                    407: up to 16381 indexed so that the smaller one has smaller
                    408: index.  The function @code{lprime()} can return one of 999 primes which
                    409: are 8 digit sized and indexed so that the larger one has the smaller
                    410: index.
                    411: The two function always returns 0 for other indices.
                    412: @item
                    413: For more general function for prime generation, there is a @code{PARI}
                    414: function
                    415:
                    416: @code{pari(nextprime,@var{number})}.
                    417: \E
1.1       noro      418: @end itemize
                    419:
                    420: @example
                    421: [95] prime(0);
                    422: 2
                    423: [96] prime(1228);
                    424: 9973
                    425: [97] lprime(0);
                    426: 99999989
                    427: [98] lprime(999);
                    428: 0
                    429: @end example
                    430:
                    431: @table @t
1.2       noro      432: \JP @item $B;2>H(B
                    433: \EG @item References
1.1       noro      434: @fref{pari}.
                    435: @end table
                    436:
1.2       noro      437: \JP @node random,,, $B?t$N1i;;(B
                    438: \EG @node random,,, Numbers
1.1       noro      439: @subsection @code{random}
                    440: @findex random
                    441:
                    442: @table @t
1.5       takayama  443: @item random([@var{seed}])
1.2       noro      444: \JP :: $BMp?t$r@8@.$9$k(B.
1.1       noro      445: @end table
                    446:
                    447: @table @var
                    448: @item seed
1.2       noro      449: @itemx return
                    450: \JP $B<+A3?t(B
                    451: \EG non-negative integer
1.1       noro      452: @end table
                    453:
                    454: @itemize @bullet
1.2       noro      455: \BJP
1.1       noro      456: @item
                    457: $B:GBg(B 2^32-1 $B$NHsIi@0?t$NMp?t$r@8@.$9$k(B.
                    458: @item
                    459: 0 $B$G$J$$0z?t$,$"$k;~(B, $B$=$NCM$r(B seed $B$H$7$F@_Dj$7$F$+$i(B, $BMp?t$r@8@.$9$k(B.
                    460: @item
                    461: default $B$N(B seed $B$O8GDj$N$?$a(B, $B<o$r@_Dj$7$J$1$l$P(B, $B@8@.$5$l$kMp?t$N(B
                    462: $B7ONs$O5/F0Kh$K0lDj$G$"$k(B.
                    463: @item
                    464: $B>>K\bC(B-$B@>B<Bs;N$K$h$k(B Mersenne Twister (http://www.math.keio.ac.jp/matsumoto/mt.html) $B%"%k%4%j%:%`$N(B, $BH`$i<+?H$K$h$k<BAu$rMQ$$$F$$$k(B.
                    465: @item
                    466: $B<~4|$O(B 2^19937-1 $B$HHs>o$KD9$$(B.
                    467: @item
                    468: @code{mt_save} $B$K$h$j(B state $B$r%U%!%$%k$K(B save $B$G$-$k(B. $B$3$l$r(B @code{mt_load}
                    469: $B$GFI$_9~$`$3$H$K$h$j(B, $B0[$k(B Asir $B%;%C%7%g%s4V$G0l$D$NMp?t$N7ONs$rC)$k$3$H$,(B
                    470: $B$G$-$k(B.
1.2       noro      471: \E
                    472: \BEG
                    473: @item
                    474: Generates a random number which is a non-negative integer less than 2^32.
                    475: @item
                    476: If a non zero argument is specified, then after setting it as a random seed,
                    477: a random number is generated.
                    478: @item
                    479: As the default seed is fixed, the sequence of the random numbers is
                    480: always the same if a seed is not set.
                    481: @item
                    482: The algorithm is Mersenne Twister
                    483: (http://www.math.keio.ac.jp/matsumoto/mt.html) by M. Matsumoto and
                    484: T. Nishimura. The implementation is done also by themselves.
                    485: @item
                    486: The period of the random number sequence is 2^19937-1.
                    487: @item
                    488: One can save the state of the random number generator with @code{mt_save}.
                    489: By loading the state file with @code{mt_load},
                    490: one can trace a single random number sequence arcoss multiple sessions.
                    491: \E
1.1       noro      492: @end itemize
                    493:
                    494: @table @t
1.2       noro      495: \JP @item $B;2>H(B
                    496: \EG @item References
1.1       noro      497: @fref{lrandom}, @fref{mt_save mt_load}.
                    498: @end table
                    499:
1.2       noro      500: \JP @node lrandom,,, $B?t$N1i;;(B
                    501: \EG @node lrandom,,, Numbers
1.1       noro      502: @subsection @code{lrandom}
                    503: @findex lrandom
                    504:
                    505: @table @t
1.5       takayama  506: @item lrandom(@var{bit})
1.2       noro      507: \JP :: $BB?G\D9Mp?t$r@8@.$9$k(B.
                    508: \EG :: Generates a long random number.
1.1       noro      509: @end table
                    510:
                    511: @table @var
                    512: @item bit
                    513: @item return
1.2       noro      514: \JP $B<+A3?t(B
                    515: \EG integer
1.1       noro      516: @end table
                    517:
                    518: @itemize @bullet
1.2       noro      519: \BJP
1.1       noro      520: @item
                    521: $B9b!9(B @var{bit} $B$NHsIi@0?t$NMp?t$r@8@.$9$k(B.
                    522: @item
                    523: @code{random} $B$rJ#?t2s8F$S=P$7$F7k9g$7(B, $B;XDj$N(B bit $BD9$K%^%9%/$7$F$$$k(B.
1.2       noro      524: \E
                    525: \BEG
                    526: @item
                    527: Generates a non-negative integer of at most @var{bit} bits.
                    528: @item
                    529: The result is a concatination of outputs of @code{random}.
                    530: \E
1.1       noro      531: @end itemize
                    532:
                    533: @table @t
1.2       noro      534: \JP @item $B;2>H(B
                    535: \EG @item References
1.1       noro      536: @fref{random}, @fref{mt_save mt_load}.
                    537: @end table
                    538:
1.2       noro      539: \JP @node mt_save mt_load,,, $B?t$N1i;;(B
                    540: \EG @node mt_save mt_load,,, Numbers
1.1       noro      541: @subsection @code{mt_save}, @code{mt_load}
                    542: @findex mt_save
                    543: @findex mt_load
                    544:
                    545: @table @t
                    546: @item mt_save(@var{fname})
1.2       noro      547: \JP :: $BMp?t@8@.4o$N8=:_$N>uBV$r%U%!%$%k$K%;!<%V$9$k(B.
                    548: \EG :: Saves the state of the random number generator.
1.1       noro      549: @item mt_load(@var{fname})
1.2       noro      550: \JP :: $B%U%!%$%k$K%;!<%V$5$l$?Mp?t@8@.4o$N>uBV$r%m!<%I$9$k(B.
                    551: \EG :: Loads a saved state of the random number generator.
1.1       noro      552: @end table
                    553:
                    554: @table @var
                    555: @item return
1.2       noro      556: \JP 0 $B$^$?$O(B 1
                    557: \EG 0 or 1
1.1       noro      558: @item fname
1.2       noro      559: \JP $BJ8;zNs(B
                    560: \EG string
1.1       noro      561: @end table
                    562:
                    563: @itemize @bullet
1.2       noro      564: \BJP
                    565: @item
                    566: $B$"$k>uBV$r%;!<%V$7(B, $B$=$N>uBV$r%m!<%I$9$k$3$H$G(B,
1.1       noro      567: $B0l$D$N5?;wMp?t7ONs$r(B, $B?75,$N(B Asir $B%;%C%7%g%s$GB3$1$F$?$I$k$3$H$,(B
                    568: $B$G$-$k(B.
1.2       noro      569: \E
                    570: \BEG
                    571: @item
                    572: One can save the state of the random number generator with @code{mt_save}.
                    573: By loading the state file with @code{mt_load},
                    574: one can trace a single random number sequence arcoss multiple
                    575: @b{Asir} sessions.
                    576: \E
1.1       noro      577: @end itemize
                    578:
                    579: @example
                    580: [340] random();
                    581: 3510405877
                    582: [341] mt_save("/tmp/mt_state");
                    583: 1
                    584: [342] random();
                    585: 4290933890
                    586: [343] quit;
                    587: % asir
                    588: This is Asir, Version 991108.
                    589: Copyright (C) FUJITSU LABORATORIES LIMITED.
                    590: 3 March 1994. All rights reserved.
                    591: [340] mt_load("/tmp/mt_state");
                    592: 1
                    593: [341] random();
                    594: 4290933890
                    595: @end example
                    596:
                    597: @table @t
1.2       noro      598: \JP @item $B;2>H(B
                    599: \EG @item References
1.1       noro      600: @fref{random}, @fref{lrandom}.
                    601: @end table
                    602:
1.2       noro      603: \JP @node nm dn,,, $B?t$N1i;;(B
                    604: \EG @node nm dn,,, Numbers
1.1       noro      605: @subsection @code{nm}, @code{dn}
                    606: @findex nm
                    607: @findex dn
                    608:
                    609: @table @t
                    610: @item nm(@var{rat})
1.2       noro      611: \JP :: @var{rat} $B$NJ,;R(B.
                    612: \EG :: Numerator of @var{rat}.
1.1       noro      613: @item dn(@var{rat})
1.2       noro      614: \JP :: @var{rat} $B$NJ,Jl(B.
                    615: \EG :: Denominator of @var{rat}.
1.1       noro      616: @end table
                    617:
                    618: @table @var
                    619: @item return
1.2       noro      620: \JP $B@0?t$^$?$OB?9`<0(B
                    621: \EG integer or polynomial
1.1       noro      622: @item rat
1.2       noro      623: \JP $BM-M}?t$^$?$OM-M}<0(B
                    624: \EG rational number or rational expression
1.1       noro      625: @end table
                    626:
                    627: @itemize @bullet
1.2       noro      628: \BJP
1.1       noro      629: @item
                    630: $BM?$($i$l$?M-M}?t$^$?M-M}<0$NJ,;R5Z$SJ,Jl$rJV$9(B.
                    631: @item
                    632: $BM-M}?t$N>l9g(B, $BJ,Jl$O>o$K@5$G(B, $BId9f$OJ,;R$,;}$D(B.
                    633: @item
                    634: $BM-M}<0$N>l9g(B, $BC1$KJ,Jl(B, $BJ,;R$r<h$j=P$9$@$1$G$"$k(B.
                    635: $BM-M}<0$KBP$7$F$O(B, $BLsJ,$O<+F0E*$K$O9T$o$l$J$$(B. @code{red()}
                    636: $B$rL@<(E*$K8F$S=P$9I,MW$,$"$k(B.
1.2       noro      637: \E
                    638: \BEG
                    639: @item
                    640: Numerator and denominator of a given rational expression.
                    641: @item
                    642: For a rational number, they return its numerator and denominator,
                    643: respectively.  For a rational expression whose numerator and denominator
                    644: may contain rational numbers, they do not separate those rational
                    645: coefficients to numerators and denominators.
                    646: @item
                    647: For a rational number, the denominator is always kept positive, and
                    648: the sign is contained in the numerator.
                    649: @item
                    650: @b{Risa/Asir} does not cancel the common divisors unless otherwise explicitly
                    651: specified by the user.
                    652: Therefore, @code{nm()} and @code{dn()} return the numerator and the
                    653: denominator as it is, respectively.
                    654: \E
1.1       noro      655: @end itemize
                    656:
                    657: @example
                    658: [2] [nm(-43/8),dn(-43/8)];
                    659: [-43,8]
                    660: [3] dn((x*z)/(x*y));
                    661: y*x
                    662: [3] dn(red((x*z)/(x*y)));
                    663: y
                    664: @end example
                    665:
                    666: @table @t
1.2       noro      667: \JP @item $B;2>H(B
                    668: \EG @item References
1.1       noro      669: @fref{red}.
                    670: @end table
                    671:
1.2       noro      672: \JP @node conj real imag,,, $B?t$N1i;;(B
                    673: \EG @node conj real imag,,, Numbers
1.1       noro      674: @subsection @code{conj}, @code{real}, @code{imag}
                    675: @findex conj
                    676:
                    677: @table @t
                    678: @item real(@var{comp})
1.2       noro      679: \JP :: @var{comp} $B$N<B?tItJ,(B.
                    680: \EG :: Real part of @var{comp}.
1.1       noro      681: @item imag(@var{comp})
1.2       noro      682: \JP :: @var{comp} $B$N5u?tItJ,(B.
                    683: \EG :: Imaginary part of @var{comp}.
1.1       noro      684: @item conj(@var{comp})
1.2       noro      685: \JP :: @var{comp} $B$N6&LrJ#AG?t(B.
                    686: \EG :: Complex conjugate of @var{comp}.
1.1       noro      687: @end table
                    688:
                    689: @table @var
                    690: @item return comp
1.2       noro      691: \JP $BJ#AG?t(B
                    692: \EG complex number
1.1       noro      693: @end table
                    694:
                    695: @itemize @bullet
1.2       noro      696: \BJP
1.1       noro      697: @item
                    698: $BJ#AG?t$KBP$7(B, $B<BIt(B, $B5uIt(B, $B6&Lr$r5a$a$k(B.
                    699: @item
                    700: $B$3$l$i$O(B, $BB?9`<0$KBP$7$F$bF/$/(B.
1.2       noro      701: \E
                    702: \BEG
                    703: @item
                    704: Basic operations for complex numbers.
                    705: @item
                    706: These functions works also for polynomials with complex coefficients.
                    707: \E
1.1       noro      708: @end itemize
                    709:
                    710: @example
                    711: [111] A=(2+@@i)^3;
                    712: (2+11*@@i)
                    713: [112] [real(A),imag(A),conj(A)];
                    714: [2,11,(2-11*@@i)]
                    715: @end example
                    716:
1.4       noro      717: \JP @node eval deval ,,, $B?t$N1i;;(B
                    718: \EG @node eval deval,,, Numbers
                    719: @subsection @code{eval}, @code{deval}
1.1       noro      720: @findex eval
1.4       noro      721: @findex deval
1.1       noro      722: @cindex PARI
                    723:
                    724: @table @t
                    725: @item eval(@var{obj}[,@var{prec}])
1.4       noro      726: @item deval(@var{obj})
1.2       noro      727: \JP :: @var{obj} $B$NCM$NI>2A(B.
                    728: \EG :: Evaluate @var{obj} numerically.
1.1       noro      729: @end table
                    730:
                    731: @table @var
                    732: @item return
1.2       noro      733: \JP $B?t$"$k$$$O<0(B
                    734: \EG number or expression
1.1       noro      735: @item obj
1.2       noro      736: \JP $B0lHL$N<0(B
                    737: \EG general expression
1.1       noro      738: @item prec
1.2       noro      739: \JP $B@0?t(B
                    740: \EG integer
1.1       noro      741: @end table
                    742:
                    743: @itemize @bullet
1.2       noro      744: \BJP
1.1       noro      745: @item
                    746: @var{obj} $B$K4^$^$l$kH!?t$NCM$r2DG=$J8B$jI>2A$9$k(B.
                    747: @item
1.4       noro      748: @code{deval} $B$OG\@:EYIbF0>.?t$r7k2L$H$7$F(B
                    749: @code{eval} $B$N>l9g(B, $BM-M}?t$O$=$N$^$^;D$k(B.
1.1       noro      750: @item
1.7       noro      751: @code{eval} $B$K$*$$$F$O(B, $B7W;;$O(B @b{PARI} (@ref{pari}) $B$,9T$&(B.
1.4       noro      752: @code{deval} $B$K$*$$$F$O(B, $B7W;;$O(B C $B?t3X%i%$%V%i%j$N4X?t$rMQ$$$F9T$&(B.
                    753: @item
                    754: @code{deval} $B$OJ#AG?t$O07$($J$$(B.
                    755: @item
                    756: @code{eval} $B$K$*$$$F$O(B,
1.1       noro      757: @var{prec} $B$r;XDj$7$?>l9g(B, $B7W;;$O(B, 10 $B?J(B @var{prec} $B7eDxEY$G9T$o$l$k(B.
                    758: @var{prec} $B$N;XDj$,$J$$>l9g(B, $B8=:_@_Dj$5$l$F$$$k@:EY$G9T$o$l$k(B.
1.7       noro      759: (@xref{setprec}.)
1.1       noro      760: @item
                    761: @table @t
                    762: @item $B07$($kH!?t$O(B, $B<!$NDL$j(B.
                    763: @code{sin}, @code{cos}, @code{tan},
                    764:
                    765: @code{asin}, @code{acos}, @code{atan},
                    766:
                    767: @code{sinh}, @code{cosh}, @code{tanh},
                    768:
                    769: @code{asinh}, @code{acosh}, @code{atanh},
                    770:
                    771: @code{exp}, @code{log}, @code{pow(a,b) (a^b)}
                    772: @end table
                    773: @item
1.4       noro      774: $B0J2<$N5-9f$r?t$H$7$FI>2A$G$-$k(B. $B$?$@$7(B @code{@@i} $B$r07$($k$N$O(B
                    775: @code{eval}, @code{deval} $B$N$_$G$"$k(B.
1.1       noro      776: @table @t
                    777: @item @@i
                    778: $B5u?tC10L(B
                    779: @item @@pi
                    780: $B1_<~N((B
                    781: @item @@e
                    782: $B<+A3BP?t$NDl(B
                    783: @end table
1.2       noro      784: \E
                    785: \BEG
                    786: @item
                    787: Evaluates the value of the functions contained in @var{obj} as far as
                    788: possible.
                    789: @item
1.4       noro      790: @code{deval} returns
                    791: double float. Rational numbers remain unchanged in results from @code{eval}.
                    792: @item
                    793: In @code{eval} the computation is done
1.7       noro      794: by @b{PARI}. (@xref{pari}.) In @code{deval} the computation is
1.4       noro      795: done by the C math library.
                    796: @item
                    797: @code{deval} cannot handle complex numbers.
1.2       noro      798: @item
                    799: When @var{prec} is specified, computation will be performed with a
                    800: precision of about @var{prec}-digits.
                    801: If @var{prec} is not specified, computation is performed with the
1.7       noro      802: precision set currently. (@xref{setprec}.)
1.2       noro      803: @item
                    804: Currently available numerical functions are listed below.
                    805: Note they are only a small part of whole @b{PARI} functions.
                    806:
                    807: @table @t
                    808: @code{sin}, @code{cos}, @code{tan},
                    809:
                    810: @code{asin}, @code{acos}, @code{atan},
                    811:
                    812: @code{sinh}, @code{cosh}, @code{tanh},
                    813: @code{asinh}, @code{acosh}, @code{atanh},
                    814:
                    815: @code{exp}, @code{log}, @code{pow(a,b) (a^b)}
                    816: @end table
                    817: @item
1.4       noro      818: Symbols for special values are as the followings. Note that
                    819: @code{@@i} cannot be handled by @code{deval}.
1.2       noro      820: @table @t
                    821: @item @@i
                    822: unit of imaginary number
                    823: @item @@pi
                    824: the number pi,
                    825: the ratio of circumference to diameter
                    826: @item @@e
                    827: Napier's number (@t{exp}(1))
                    828: @end table
                    829: \E
1.1       noro      830: @end itemize
                    831:
                    832: @example
                    833: [118] eval(exp(@@pi*@@i));
                    834: -1.0000000000000000000000000000
                    835: [119] eval(2^(1/2));
                    836: 1.414213562373095048763788073031
                    837: [120] eval(sin(@@pi/3));
                    838: 0.86602540378443864674620506632
                    839: [121] eval(sin(@@pi/3)-3^(1/2)/2,50);
                    840: -2.78791084448179148471 E-58
1.4       noro      841: [122] eval(1/2);
                    842: 1/2
                    843: [123] deval(sin(1)^2+cos(1)^2);
                    844: 1
1.1       noro      845: @end example
                    846:
                    847: @table @t
1.2       noro      848: \JP @item $B;2>H(B
                    849: \EG @item References
1.1       noro      850: @fref{ctrl}, @fref{setprec}, @fref{pari}.
                    851: @end table
                    852:
1.2       noro      853: \JP @node pari,,, $B?t$N1i;;(B
                    854: \EG @node pari,,, Numbers
1.1       noro      855: @subsection @code{pari}
                    856: @findex pari
                    857: @cindex PARI
                    858:
                    859: @table @t
                    860: @item pari(@var{func},@var{arg},@var{prec})
1.2       noro      861: \JP :: @b{PARI} $B$NH!?t(B @var{func} $B$r8F$S=P$9(B.
                    862: \EG :: Call @b{PARI} function @var{func}.
1.1       noro      863: @end table
                    864:
                    865: @table @var
                    866: @item return
1.2       noro      867: \JP @var{func} $BKh$K0[$J$k(B.
                    868: \EG Depends on @var{func}.
1.1       noro      869: @item func
1.2       noro      870: \JP @b{PARI} $B$NH!?tL>(B
                    871: \EG Function name of @b{PARI}.
1.1       noro      872: @item arg
1.2       noro      873: \JP @var{func} $B$N0z?t(B
                    874: \EG Arguments of @var{func}.
1.1       noro      875: @item prec
1.2       noro      876: \JP $B@0?t(B
                    877: \EG integer
1.1       noro      878: @end table
                    879:
                    880: @itemize @bullet
1.2       noro      881: \BJP
1.1       noro      882: @item
                    883: @b{PARI} $B$NH!?t$r8F$S=P$9(B.
                    884:
                    885: @item
                    886: @b{PARI} @code{[Batut et al.]} $B$O(B Bordeaux $BBg3X$G3+H/$5$l%U(B
                    887: $B%j!<%=%U%H%&%'%"$H$7$F8x3+$5$l$F$$$k(B. @b{PARI} $B$O?t<0=hM}E*$J5!G=$rM-(B
                    888: $B$7$F$O$$$k$,(B, $B<g$J%?!<%2%C%H$O@0?tO@$K4XO"$7$??t(B (@b{bignum},
                    889: @b{bigfloat}) $B$N1i;;$G(B, $B;MB'1i;;$K8B$i$:(B@b{bigfloat} $B$K$h$k$5$^$6$^$J(B
                    890: $BH!?tCM$NI>2A$r9bB.$K9T$&$3$H$,$G$-$k(B. @b{PARI} $B$OB>$N%W%m%0%i%`$+$i(B
                    891: $B%5%V%k!<%A%s%i%$%V%i%j$H$7$FMQ$$$k$3$H$,$G$-(B, $B$^$?(B, @samp{gp} $B$H$$$&(B
                    892: @b{PARI}$B%i%$%V%i%j$N%$%s%?%U%'!<%9$K$h$j(B UNIX $B$N%"%W%j%1!<%7%g%s$H$7$F(B
1.2       noro      893: $BMxMQ$9$k$3$H$b$G$-$k(B. $B8=:_$N%P!<%8%g%s$O(B @b{2.0.17beta} $B$G$$$/$D$+$N(B ftp
                    894: site ($B$?$H$($P(B @code{ftp://megrez.ceremab.u-bordeaux.fr/pub/pari})
1.1       noro      895: $B$+$i(B anonymous ftp $B$G$-$k(B.
                    896: @item
                    897: $B:G8e$N0z?t(B @var{prec} $B$G7W;;@:EY$r;XDj$G$-$k(B.
                    898: @var{prec} $B$r>JN,$7$?>l9g(B @code{setprec()} $B$G;XDj$7$?@:EY$H$J$k(B.
                    899: @item
                    900: $B8=;~E@$G<B9T$G$-$k(B @b{PARI} $B$NH!?t$O<!$NDL$j$G$"$k(B. $B$$$:$l$b(B
                    901: 1 $B0z?t$G(B @b{Asir} $B$,BP1~$G$-$k7?$N0z?t$r$H$kH!?t$G$"$k(B.
                    902: $B$J$*3F!9$N5!G=$K$D$$$F$O(B @b{PARI} $B$N%^%K%e%"%k$r;2>H$N$3$H(B.
1.2       noro      903: \E
                    904: \BEG
                    905: @item
                    906: This command connects @b{Asir} to @b{PARI} system so that several
                    907: functions of @b{PARI} can be conveniently used from @b{Risa/Asir}.
                    908: @item
                    909: @b{PARI} @code{[Batut et al.]} is developed at Bordeaux University, and
                    910: distributed as a free software.  Though it has a certain facility to computer
                    911: algebra, its major target is the operation of numbers (@b{bignum},
                    912: @b{bigfloat}) related to the number theory.  It facilitates various
                    913: function evaluations as well as arithmetic operations at a remarkable
                    914: speed.  It can also be used from other external programs as a library.
                    915: It provides a language interface named @samp{gp} to its library, which
                    916: enables a user to use @b{PARI} as a calculator which runs on UNIX.
                    917: The current version is @b{2.0.17beta}.  It can be obtained by several ftp
                    918: sites. (For example, @code{ftp://megrez.ceremab.u-bordeaux.fr/pub/pari}.)
                    919: @item
                    920: The last argument (optional) @var{int} specifies the precision in digits
                    921: for bigfloat operation.
                    922: If the precision is not explicitly specified, operation will be performed
                    923: with the precision set by @code{setprec()}.
                    924: @item
                    925: Currently available functions of @b{PARI} system are as follows.
                    926: Note these are only a part of functions in @b{PARI} system.
                    927: For details of individual functions, refer to the @b{PARI} manual.
                    928: (Some of them can be seen in the following example.)
                    929: \E
1.1       noro      930:
                    931: @code{abs},
                    932: @code{adj},
                    933: @code{arg},
                    934: @code{bigomega},
                    935: @code{binary},
                    936: @code{ceil},
                    937: @code{centerlift},
                    938: @code{cf},
                    939: @code{classno},
                    940: @code{classno2},
                    941: @code{conj},
                    942: @code{content},
                    943: @code{denom},
                    944: @code{det},
                    945: @code{det2},
                    946: @code{detr},
                    947: @code{dilog},
                    948: @code{disc},
                    949: @code{discf},
                    950: @code{divisors},
                    951: @code{eigen},
                    952: @code{eintg1},
                    953: @code{erfc},
                    954: @code{eta},
                    955: @code{floor},
                    956: @code{frac},
                    957: @code{galois},
                    958: @code{galoisconj},
                    959: @code{gamh},
                    960: @code{gamma},
                    961: @code{hclassno},
                    962: @code{hermite},
                    963: @code{hess},
                    964: @code{imag},
                    965: @code{image},
                    966: @code{image2},
                    967: @code{indexrank},
                    968: @code{indsort},
                    969: @code{initalg},
                    970: @code{isfund},
                    971: @code{isprime},
                    972: @code{ispsp},
                    973: @code{isqrt},
                    974: @code{issqfree},
                    975: @code{issquare},
                    976: @code{jacobi},
                    977: @code{jell},
                    978: @code{ker},
                    979: @code{keri},
                    980: @code{kerint},
                    981: @code{kerintg1},
                    982: @code{kerint2},
                    983: @code{kerr},
                    984: @code{length},
                    985: @code{lexsort},
                    986: @code{lift},
                    987: @code{lindep},
                    988: @code{lll},
                    989: @code{lllg1},
                    990: @code{lllgen},
                    991: @code{lllgram},
                    992: @code{lllgramg1},
                    993: @code{lllgramgen},
                    994: @code{lllgramint},
                    995: @code{lllgramkerim},
                    996: @iftex
                    997: @break
                    998: @end iftex
                    999: @code{lllgramkerimgen},
                   1000: @code{lllint},
                   1001: @code{lllkerim},
                   1002: @code{lllkerimgen},
                   1003: @code{lllrat},
                   1004: @code{lngamma},
                   1005: @code{logagm},
                   1006: @code{mat},
                   1007: @code{matrixqz2},
                   1008: @code{matrixqz3},
                   1009: @code{matsize},
                   1010: @code{modreverse},
                   1011: @code{mu},
                   1012: @code{nextprime},
                   1013: @code{norm},
                   1014: @code{norml2},
                   1015: @code{numdiv},
                   1016: @code{numer},
                   1017: @code{omega},
                   1018: @code{order},
                   1019: @code{ordred},
                   1020: @code{phi},
                   1021: @code{pnqn},
                   1022: @code{polred},
                   1023: @code{polred2},
                   1024: @code{primroot},
                   1025: @code{psi},
                   1026: @code{quadgen},
                   1027: @code{quadpoly},
                   1028: @code{real},
                   1029: @code{recip},
                   1030: @code{redcomp},
                   1031: @code{redreal},
                   1032: @code{regula},
                   1033: @code{reorder},
                   1034: @code{reverse},
                   1035: @code{rhoreal},
                   1036: @code{roots},
                   1037: @code{rootslong},
                   1038: @code{round},
                   1039: @code{sigma},
                   1040: @code{signat},
                   1041: @code{simplify},
                   1042: @code{smalldiscf},
                   1043: @code{smallfact},
                   1044: @code{smallpolred},
                   1045: @code{smallpolred2},
                   1046: @code{smith},
                   1047: @code{smith2},
                   1048: @code{sort},
                   1049: @code{sqr},
                   1050: @code{sqred},
                   1051: @code{sqrt},
                   1052: @code{supplement},
                   1053: @code{trace},
                   1054: @code{trans},
                   1055: @code{trunc},
                   1056: @code{type},
                   1057: @code{unit},
                   1058: @code{vec},
                   1059: @code{wf},
                   1060: @code{wf2},
                   1061: @code{zeta}
                   1062:
1.2       noro     1063: \BJP
1.1       noro     1064: @item
                   1065: @b{Asir} $B$GMQ$$$F$$$k$N$O(B @b{PARI} $B$N$[$s$N0lIt$N5!G=$G$"$k$,(B, $B:#8e(B
                   1066: $B$h$jB?$/$N5!G=$,MxMQ$G$-$k$h$&2~NI$9$kM=Dj$G$"$k(B.
1.2       noro     1067: \E
                   1068: \BEG
                   1069: @item
                   1070: @b{Asir} currently uses only a very small subset of @b{PARI}.
                   1071: We will improve @b{Asir} so that it can provide more functions of
                   1072: @b{PARI}.
                   1073: \E
1.1       noro     1074: @end itemize
                   1075:
                   1076: @example
1.2       noro     1077: \JP /* $B9TNs$N8GM-%Y%/%H%k$r5a$a$k(B. */
                   1078: \EG /* Eigen vectors of a numerical matrix */
1.1       noro     1079: [0] pari(eigen,newmat(2,2,[[1,1],[1,2]]));
                   1080: [ -1.61803398874989484819771921990 0.61803398874989484826 ]
                   1081: [ 1 1 ]
1.2       noro     1082: \JP /* 1 $BJQ?tB?9`<0$N:,$r5a$a$k(B. */
                   1083: \EG /* Roots of a polynomial */
1.1       noro     1084: [1] pari(roots,t^2-2);
                   1085: [ -1.41421356237309504876 1.41421356237309504876 ]
                   1086: @end example
                   1087:
                   1088: @table @t
1.2       noro     1089: \JP @item $B;2>H(B
                   1090: \EG @item References
1.1       noro     1091: @fref{setprec}.
                   1092: @end table
                   1093:
1.2       noro     1094: \JP @node setprec,,, $B?t$N1i;;(B
                   1095: \EG @node setprec,,, Numbers
1.1       noro     1096: @subsection @code{setprec}
                   1097: @findex setprec
                   1098: @cindex PARI
                   1099:
                   1100: @table @t
                   1101: @item setprec([@var{n}])
1.2       noro     1102: \JP :: @b{bigfloat} $B$N7e?t$r(B @var{n} $B7e$K@_Dj$9$k(B.
                   1103: \EG :: Sets the precision for @b{bigfloat} operations to @var{n} digits.
1.1       noro     1104: @end table
                   1105:
                   1106: @table @var
                   1107: @item return
1.2       noro     1108: \JP $B@0?t(B
                   1109: \EG integer
1.1       noro     1110: @item n
1.2       noro     1111: \JP $B@0?t(B
                   1112: \EG integer
1.1       noro     1113: @end table
                   1114:
                   1115: @itemize @bullet
1.2       noro     1116: \BJP
1.1       noro     1117: @item
                   1118: $B0z?t$,$"$k>l9g(B, @b{bigfloat} $B$N7e?t$r(B @var{n} $B7e$K@_Dj$9$k(B.
                   1119: $B0z?t$N$"$k$J$7$K$+$+$o$i$:(B, $B0JA0$K@_Dj$5$l$F$$$?CM$rJV$9(B.
                   1120: @item
1.7       noro     1121: @b{bigfloat} $B$N7W;;$O(B @b{PARI} (@ref{pari}) $B$K$h$C$F9T$o$l$k(B.
1.1       noro     1122: @item
                   1123: @b{bigfloat} $B$G$N7W;;$KBP$7M-8z$G$"$k(B.
                   1124: @b{bigfloat} $B$N(B flag $B$r(B on $B$K$9$kJ}K!$O(B, @code{ctrl} $B$r;2>H(B.
                   1125: @item
                   1126: $B@_Dj$G$-$k7e?t$K>e8B$O$J$$$,(B, $B;XDj$7$?7e?t$K@_Dj$5$l$k$H$O(B
                   1127: $B8B$i$J$$(B. $BBg$-$a$NCM$r@_Dj$9$k$N$,0BA4$G$"$k(B.
1.2       noro     1128: \E
                   1129: \BEG
                   1130: @item
                   1131: When an argument is given, it
                   1132: sets the precision for @b{bigfloat} operations to @var{n} digits.
                   1133: The return value is always the previous precision in digits regardless of
                   1134: the existence of an argument.
                   1135:
                   1136: @item
1.7       noro     1137: @b{Bigfloat} operations are done by @b{PARI}. (@xref{pari}.)
1.2       noro     1138: @item
                   1139: This is effective for computations in @b{bigfloat}.
                   1140: Refer to @code{ctrl()} for turning on the `@b{bigfloat} flag.'
                   1141: @item
                   1142: There is no upper limit for precision digits.
                   1143: It sets the precision to some digits around the specified precision.
                   1144: Therefore, it is safe to specify a larger value.
                   1145: \E
1.1       noro     1146: @end itemize
                   1147:
                   1148: @example
                   1149: [1] setprec();
                   1150: 9
                   1151: [2] setprec(100);
                   1152: 9
                   1153: [3] setprec(100);
                   1154: 96
                   1155: @end example
                   1156:
                   1157: @table @t
1.2       noro     1158: \JP @item $B;2>H(B
1.4       noro     1159: @fref{ctrl}, @fref{eval deval}, @fref{pari}.
1.1       noro     1160: @end table
                   1161:
1.2       noro     1162: \JP @node setmod,,, $B?t$N1i;;(B
                   1163: \EG @node setmod,,, Numbers
1.1       noro     1164: @subsection @code{setmod}
                   1165: @findex setmod
                   1166:
                   1167: @table @t
                   1168: @item setmod([@var{p}])
1.2       noro     1169: \JP :: $BM-8BBN$r(B GF(@var{p}) $B$K@_Dj$9$k(B.
                   1170: \EG :: Sets the ground field to GF(@var{p}).
1.1       noro     1171: @end table
                   1172:
                   1173: @table @var
                   1174: @item return
1.2       noro     1175: \JP $B@0?t(B
                   1176: \EG integer
1.1       noro     1177: @item n
1.2       noro     1178: \JP 2^27 $BL$K~$NAG?t(B
                   1179: \EG prime less than 2^27
1.1       noro     1180: @end table
                   1181:
                   1182: @itemize @bullet
1.2       noro     1183: \BJP
1.1       noro     1184: @item
                   1185: $BM-8BBN$r(B GF(@var{p}) $B$K@_Dj$9$k(B. $B@_DjCM$rJV$9(B.
                   1186: @item
                   1187: $BM-8BBN$N85$N7?$r;}$D?t$O(B, $B$=$l<+?H$O$I$NM-8BBN$KB0$9$k$+$N>pJs$r;}$?$:(B,
                   1188: $B8=:_@_Dj$5$l$F$$$kAG?t(B @var{p} $B$K$h$j(B GF(@var{p}) $B>e$G$N1i;;$,E,MQ$5$l$k(B.
1.2       noro     1189: @item
                   1190: $B0L?t$NBg$-$JM-8BBN$K4X$7$F$O(B @pxref{$BM-8BBN$K4X$9$k1i;;(B}.
                   1191: \E
                   1192: \BEG
                   1193: @item
                   1194: Sets the ground field to GF(@var{p}) and returns the value @var{p}.
                   1195: @item
                   1196: A member of a finite field does not have any information
                   1197: about the field and the arithmetic operations over GF(@var{p}) are applied
                   1198: with @var{p} set at the time.
                   1199: @item
                   1200: As for large finite fields, @pxref{Finite fields}.
                   1201: \E
1.1       noro     1202: @end itemize
                   1203:
                   1204: @example
                   1205: [0] A=dp_mod(dp_ptod(2*x,[x]),3,[]);
                   1206: (2)*<<1>>
                   1207: [1] A+A;
                   1208: addmi : invalid modulus
                   1209: return to toplevel
                   1210: [1] setmod(3);
                   1211: 3
                   1212: [2] A+A;
                   1213: (1)*<<1>>
                   1214: @end example
                   1215:
                   1216: @table @t
1.2       noro     1217: \JP @item $B;2>H(B
                   1218: \EG @item References
                   1219: \JP @fref{dp_mod dp_rat}, @fref{$B?t$N7?(B}.
                   1220: \EG @fref{dp_mod dp_rat}, @fref{Types of numbers}.
1.1       noro     1221: @end table
                   1222:
1.3       noro     1223: \JP @node ntoint32 int32ton,,, $B?t$N1i;;(B
                   1224: \EG @node ntoint32 int32ton,,, Numbers
                   1225: @subsection @code{ntoint32}, @code{int32ton}
                   1226: @findex ntoint32
                   1227: @findex int32ton
                   1228:
                   1229: @table @t
                   1230: @item ntoint32(@var{n})
                   1231: @itemx int32ton(@var{int32})
                   1232: \JP :: $BHsIi@0?t$HId9f$J$7(B 32bit $B@0?t$N4V$N7?JQ49(B.
                   1233: \EG :: Type-conversion between a non-negative integer and an unsigned 32bit integer.
                   1234: @end table
                   1235:
                   1236: @table @var
                   1237: @item return
                   1238: \JP $BId9f$J$7(B 32bit $B@0?t$^$?$OHsIi@0?t(B
                   1239: \EG unsigned 32bit integer or non-negative integer
                   1240: @item n
                   1241: \JP 2^32 $BL$K~$NHsIi@0?t(B
                   1242: \EG non-negative interger less than 2^32
                   1243: @item int32
                   1244: \JP $BId9f$J$7(B 32bit $B@0?t(B
                   1245: \EG unsigned 32bit integer
                   1246: @end table
                   1247:
                   1248: @itemize @bullet
                   1249: \BJP
                   1250: @item $BHsIi@0?t(B ($B<1JL;R(B 1) $B$NId9f$J$7(B 32bit $B@0?t(B ($B<1JL;R(B 10) $B$X$NJQ49(B,
                   1251: $B$^$?$O$=$N5UJQ49$r9T$&(B.
                   1252: @item 32bit $B@0?t$O(B @b{OpenXM} $B$N4pK\9=@.MWAG$G$"$j(B, $B@0?t$r$=$N7?$GAw?.(B
                   1253: $B$9$kI,MW$,$"$k>l9g$KMQ$$$k(B.
                   1254: \E
                   1255: \BEG
                   1256: @item These functions do conversions between non-negative
                   1257: integers (the type id 1) and unsigned 32bit integers (the type id 10).
                   1258: @item An unsigned 32bit integer is a fundamental construct of @b{OpenXM}
                   1259: and one often has to send an integer to a server as an unsigned 32bit
                   1260: integer. These functions are used in such a case.
                   1261: \E
                   1262: @end itemize
                   1263:
                   1264: @table @t
                   1265: \JP @item $B;2>H(B
                   1266: \EG @item References
                   1267: \JP @fref{$BJ,;67W;;(B}, @fref{$B?t$N7?(B}.
                   1268: \EG @fref{Distributed computation}, @fref{Types of numbers}.
                   1269: @end table

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