[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.11

1.11    ! noro        1: @comment $OpenXM: OpenXM/src/asir-doc/parts/builtin/num.texi,v 1.10 2003/12/20 20:02:28 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.11    ! noro      751: @code{eval} $B$K$*$$$F$O(B, $B7W;;$O(B @b{MPFR} $B%i%$%V%i%j$,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.11    ! noro      759: (@xref{setprec}, @xref{setbprec}.)
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.11    ! noro      794: by @b{MPFR} library. 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:
                    806: @table @t
                    807: @code{sin}, @code{cos}, @code{tan},
                    808:
                    809: @code{asin}, @code{acos}, @code{atan},
                    810:
                    811: @code{sinh}, @code{cosh}, @code{tanh},
                    812: @code{asinh}, @code{acosh}, @code{atanh},
                    813:
                    814: @code{exp}, @code{log}, @code{pow(a,b) (a^b)}
                    815: @end table
                    816: @item
1.4       noro      817: Symbols for special values are as the followings. Note that
                    818: @code{@@i} cannot be handled by @code{deval}.
1.2       noro      819: @table @t
                    820: @item @@i
                    821: unit of imaginary number
                    822: @item @@pi
                    823: the number pi,
                    824: the ratio of circumference to diameter
                    825: @item @@e
                    826: Napier's number (@t{exp}(1))
                    827: @end table
                    828: \E
1.1       noro      829: @end itemize
                    830:
                    831: @example
                    832: [118] eval(exp(@@pi*@@i));
                    833: -1.0000000000000000000000000000
                    834: [119] eval(2^(1/2));
                    835: 1.414213562373095048763788073031
                    836: [120] eval(sin(@@pi/3));
                    837: 0.86602540378443864674620506632
                    838: [121] eval(sin(@@pi/3)-3^(1/2)/2,50);
                    839: -2.78791084448179148471 E-58
1.4       noro      840: [122] eval(1/2);
                    841: 1/2
                    842: [123] deval(sin(1)^2+cos(1)^2);
                    843: 1
1.1       noro      844: @end example
                    845:
                    846: @table @t
1.2       noro      847: \JP @item $B;2>H(B
                    848: \EG @item References
1.11    ! noro      849: @fref{ctrl}, @fref{setprec}, @fref{setbprec}.
1.1       noro      850: @end table
                    851:
1.2       noro      852: \JP @node pari,,, $B?t$N1i;;(B
                    853: \EG @node pari,,, Numbers
1.1       noro      854: @subsection @code{pari}
                    855: @findex pari
                    856: @cindex PARI
                    857:
                    858: @table @t
                    859: @item pari(@var{func},@var{arg},@var{prec})
1.2       noro      860: \JP :: @b{PARI} $B$NH!?t(B @var{func} $B$r8F$S=P$9(B.
                    861: \EG :: Call @b{PARI} function @var{func}.
1.1       noro      862: @end table
                    863:
                    864: @table @var
                    865: @item return
1.2       noro      866: \JP @var{func} $BKh$K0[$J$k(B.
                    867: \EG Depends on @var{func}.
1.1       noro      868: @item func
1.2       noro      869: \JP @b{PARI} $B$NH!?tL>(B
                    870: \EG Function name of @b{PARI}.
1.1       noro      871: @item arg
1.2       noro      872: \JP @var{func} $B$N0z?t(B
                    873: \EG Arguments of @var{func}.
1.1       noro      874: @item prec
1.2       noro      875: \JP $B@0?t(B
                    876: \EG integer
1.1       noro      877: @end table
                    878:
                    879: @itemize @bullet
1.2       noro      880: \BJP
1.1       noro      881: @item
                    882: @b{PARI} $B$NH!?t$r8F$S=P$9(B.
                    883:
                    884: @item
                    885: @b{PARI} @code{[Batut et al.]} $B$O(B Bordeaux $BBg3X$G3+H/$5$l%U(B
                    886: $B%j!<%=%U%H%&%'%"$H$7$F8x3+$5$l$F$$$k(B. @b{PARI} $B$O?t<0=hM}E*$J5!G=$rM-(B
                    887: $B$7$F$O$$$k$,(B, $B<g$J%?!<%2%C%H$O@0?tO@$K4XO"$7$??t(B (@b{bignum},
                    888: @b{bigfloat}) $B$N1i;;$G(B, $B;MB'1i;;$K8B$i$:(B@b{bigfloat} $B$K$h$k$5$^$6$^$J(B
                    889: $BH!?tCM$NI>2A$r9bB.$K9T$&$3$H$,$G$-$k(B. @b{PARI} $B$OB>$N%W%m%0%i%`$+$i(B
                    890: $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
                    891: @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.11    ! noro      892: $BMxMQ$9$k$3$H$b$G$-$k(B.
1.1       noro      893: @item
                    894: $B:G8e$N0z?t(B @var{prec} $B$G7W;;@:EY$r;XDj$G$-$k(B.
                    895: @var{prec} $B$r>JN,$7$?>l9g(B @code{setprec()} $B$G;XDj$7$?@:EY$H$J$k(B.
                    896: @item
                    897: $B8=;~E@$G<B9T$G$-$k(B @b{PARI} $B$NH!?t$O<!$NDL$j$G$"$k(B. $B$$$:$l$b(B
                    898: 1 $B0z?t$G(B @b{Asir} $B$,BP1~$G$-$k7?$N0z?t$r$H$kH!?t$G$"$k(B.
                    899: $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      900: \E
                    901: \BEG
                    902: @item
                    903: This command connects @b{Asir} to @b{PARI} system so that several
                    904: functions of @b{PARI} can be conveniently used from @b{Risa/Asir}.
                    905: @item
                    906: @b{PARI} @code{[Batut et al.]} is developed at Bordeaux University, and
                    907: distributed as a free software.  Though it has a certain facility to computer
                    908: algebra, its major target is the operation of numbers (@b{bignum},
                    909: @b{bigfloat}) related to the number theory.  It facilitates various
                    910: function evaluations as well as arithmetic operations at a remarkable
                    911: speed.  It can also be used from other external programs as a library.
                    912: It provides a language interface named @samp{gp} to its library, which
                    913: enables a user to use @b{PARI} as a calculator which runs on UNIX.
                    914: @item
                    915: The last argument (optional) @var{int} specifies the precision in digits
                    916: for bigfloat operation.
                    917: If the precision is not explicitly specified, operation will be performed
                    918: with the precision set by @code{setprec()}.
                    919: @item
                    920: Currently available functions of @b{PARI} system are as follows.
                    921: Note these are only a part of functions in @b{PARI} system.
                    922: For details of individual functions, refer to the @b{PARI} manual.
                    923: (Some of them can be seen in the following example.)
                    924: \E
1.1       noro      925:
                    926: @code{abs},
                    927: @code{adj},
                    928: @code{arg},
                    929: @code{bigomega},
                    930: @code{binary},
                    931: @code{ceil},
                    932: @code{centerlift},
                    933: @code{cf},
                    934: @code{classno},
                    935: @code{classno2},
                    936: @code{conj},
                    937: @code{content},
                    938: @code{denom},
                    939: @code{det},
                    940: @code{det2},
                    941: @code{detr},
                    942: @code{dilog},
                    943: @code{disc},
                    944: @code{discf},
                    945: @code{divisors},
                    946: @code{eigen},
                    947: @code{eintg1},
                    948: @code{erfc},
                    949: @code{eta},
                    950: @code{floor},
                    951: @code{frac},
                    952: @code{galois},
                    953: @code{galoisconj},
                    954: @code{gamh},
                    955: @code{gamma},
                    956: @code{hclassno},
                    957: @code{hermite},
                    958: @code{hess},
                    959: @code{imag},
                    960: @code{image},
                    961: @code{image2},
                    962: @code{indexrank},
                    963: @code{indsort},
                    964: @code{initalg},
                    965: @code{isfund},
                    966: @code{isprime},
                    967: @code{ispsp},
                    968: @code{isqrt},
                    969: @code{issqfree},
                    970: @code{issquare},
                    971: @code{jacobi},
                    972: @code{jell},
                    973: @code{ker},
                    974: @code{keri},
                    975: @code{kerint},
                    976: @code{kerintg1},
                    977: @code{kerint2},
                    978: @code{kerr},
                    979: @code{length},
                    980: @code{lexsort},
                    981: @code{lift},
                    982: @code{lindep},
                    983: @code{lll},
                    984: @code{lllg1},
                    985: @code{lllgen},
                    986: @code{lllgram},
                    987: @code{lllgramg1},
                    988: @code{lllgramgen},
                    989: @code{lllgramint},
                    990: @code{lllgramkerim},
                    991: @iftex
                    992: @break
                    993: @end iftex
                    994: @code{lllgramkerimgen},
                    995: @code{lllint},
                    996: @code{lllkerim},
                    997: @code{lllkerimgen},
                    998: @code{lllrat},
                    999: @code{lngamma},
                   1000: @code{logagm},
                   1001: @code{mat},
                   1002: @code{matrixqz2},
                   1003: @code{matrixqz3},
                   1004: @code{matsize},
                   1005: @code{modreverse},
                   1006: @code{mu},
                   1007: @code{nextprime},
                   1008: @code{norm},
                   1009: @code{norml2},
                   1010: @code{numdiv},
                   1011: @code{numer},
                   1012: @code{omega},
                   1013: @code{order},
                   1014: @code{ordred},
                   1015: @code{phi},
                   1016: @code{pnqn},
                   1017: @code{polred},
                   1018: @code{polred2},
                   1019: @code{primroot},
                   1020: @code{psi},
                   1021: @code{quadgen},
                   1022: @code{quadpoly},
                   1023: @code{real},
                   1024: @code{recip},
                   1025: @code{redcomp},
                   1026: @code{redreal},
                   1027: @code{regula},
                   1028: @code{reorder},
                   1029: @code{reverse},
                   1030: @code{rhoreal},
                   1031: @code{roots},
                   1032: @code{rootslong},
                   1033: @code{round},
                   1034: @code{sigma},
                   1035: @code{signat},
                   1036: @code{simplify},
                   1037: @code{smalldiscf},
                   1038: @code{smallfact},
                   1039: @code{smallpolred},
                   1040: @code{smallpolred2},
                   1041: @code{smith},
                   1042: @code{smith2},
                   1043: @code{sort},
                   1044: @code{sqr},
                   1045: @code{sqred},
                   1046: @code{sqrt},
                   1047: @code{supplement},
                   1048: @code{trace},
                   1049: @code{trans},
                   1050: @code{trunc},
                   1051: @code{type},
                   1052: @code{unit},
                   1053: @code{vec},
                   1054: @code{wf},
                   1055: @code{wf2},
                   1056: @code{zeta}
                   1057:
1.2       noro     1058: \BJP
1.1       noro     1059: @item
1.11    ! noro     1060: @b{Asir} $B$GMQ$$$F$$$k$N$O(B @b{PARI} $B$N$[$s$N0lIt$N5!G=$G$"$k(B.
1.2       noro     1061: \E
                   1062: \BEG
                   1063: @item
                   1064: @b{Asir} currently uses only a very small subset of @b{PARI}.
                   1065: \E
1.1       noro     1066: @end itemize
                   1067:
                   1068: @example
1.2       noro     1069: \JP /* $B9TNs$N8GM-%Y%/%H%k$r5a$a$k(B. */
                   1070: \EG /* Eigen vectors of a numerical matrix */
1.1       noro     1071: [0] pari(eigen,newmat(2,2,[[1,1],[1,2]]));
                   1072: [ -1.61803398874989484819771921990 0.61803398874989484826 ]
                   1073: [ 1 1 ]
1.2       noro     1074: \JP /* 1 $BJQ?tB?9`<0$N:,$r5a$a$k(B. */
                   1075: \EG /* Roots of a polynomial */
1.1       noro     1076: [1] pari(roots,t^2-2);
                   1077: [ -1.41421356237309504876 1.41421356237309504876 ]
                   1078: @end example
                   1079:
                   1080: @table @t
1.2       noro     1081: \JP @item $B;2>H(B
                   1082: \EG @item References
1.1       noro     1083: @fref{setprec}.
                   1084: @end table
                   1085:
1.11    ! noro     1086: \JP @node setbprec setprec,,, $B?t$N1i;;(B
        !          1087: \EG @node setbprec setprec,,, Numbers
        !          1088: @subsection @code{setbprec}, @code{setprec}
        !          1089: @findex setbprec
1.1       noro     1090: @findex setprec
                   1091:
                   1092: @table @t
1.11    ! noro     1093: @item setbprec([@var{n}])
        !          1094: @itemx setprec([@var{n}])
        !          1095: \JP :: @b{setbprec}, @b{setprec} $B$O(B @b{bigfloat} $B$N@:EY$r$=$l$>$l(B 2 $B?J(B, 10$B?J(B @var{n} $B7e$K@_Dj$9$k(B.
        !          1096: \EG :: @b{setbprec}, @b{setprec} set the precision for @b{bigfloat} operations to @var{n} bits, @var{n} digits respectively.
1.1       noro     1097: @end table
                   1098:
                   1099: @table @var
                   1100: @item return
1.2       noro     1101: \JP $B@0?t(B
                   1102: \EG integer
1.1       noro     1103: @item n
1.2       noro     1104: \JP $B@0?t(B
                   1105: \EG integer
1.1       noro     1106: @end table
                   1107:
                   1108: @itemize @bullet
1.2       noro     1109: \BJP
1.1       noro     1110: @item
                   1111: $B0z?t$,$"$k>l9g(B, @b{bigfloat} $B$N7e?t$r(B @var{n} $B7e$K@_Dj$9$k(B.
                   1112: $B0z?t$N$"$k$J$7$K$+$+$o$i$:(B, $B0JA0$K@_Dj$5$l$F$$$?CM$rJV$9(B.
                   1113: @item
1.11    ! noro     1114: @b{bigfloat} $B$N7W;;$O(B @b{MPFR} $B%i%$%V%i%j$K$h$C$F9T$o$l$k(B.
1.1       noro     1115: @item
                   1116: @b{bigfloat} $B$G$N7W;;$KBP$7M-8z$G$"$k(B.
                   1117: @b{bigfloat} $B$N(B flag $B$r(B on $B$K$9$kJ}K!$O(B, @code{ctrl} $B$r;2>H(B.
                   1118: @item
                   1119: $B@_Dj$G$-$k7e?t$K>e8B$O$J$$$,(B, $B;XDj$7$?7e?t$K@_Dj$5$l$k$H$O(B
                   1120: $B8B$i$J$$(B. $BBg$-$a$NCM$r@_Dj$9$k$N$,0BA4$G$"$k(B.
1.2       noro     1121: \E
                   1122: \BEG
                   1123: @item
1.11    ! noro     1124: When an argument @var{n} is given, these functions
        !          1125: set the precision for @b{bigfloat} operations to @var{n} bits or @var{n} digits.
        !          1126: The return value is always the previous precision regardless of
1.2       noro     1127: the existence of an argument.
                   1128:
                   1129: @item
1.11    ! noro     1130: @b{Bigfloat} operations are done by @b{MPFR} library.
1.2       noro     1131: @item
                   1132: This is effective for computations in @b{bigfloat}.
                   1133: Refer to @code{ctrl()} for turning on the `@b{bigfloat} flag.'
                   1134: @item
                   1135: There is no upper limit for precision digits.
                   1136: It sets the precision to some digits around the specified precision.
                   1137: Therefore, it is safe to specify a larger value.
                   1138: \E
1.1       noro     1139: @end itemize
                   1140:
                   1141: @example
                   1142: [1] setprec();
1.11    ! noro     1143: 15
        !          1144: [2] setprec(100);
        !          1145: 15
        !          1146: [3] setprec(100);
        !          1147: 99
        !          1148: [4] setbprec();
        !          1149: 332
        !          1150: @end example
        !          1151:
        !          1152: @table @t
        !          1153: \JP @item $B;2>H(B
        !          1154: @fref{ctrl}, @fref{eval deval}.
        !          1155: @end table
        !          1156:
        !          1157: \JP @node setround,,, $B?t$N1i;;(B
        !          1158: \EG @node setround,,, Numbers
        !          1159: @subsection @code{setround}
        !          1160: @findex setround
        !          1161:
        !          1162: @table @t
        !          1163: @item setround([@var{mode}])
        !          1164: \JP :: @b{bigfloat} $B$N4]$a%b!<%I$r(B @var{mode} $B$K@_Dj$9$k(B.
        !          1165: \EG :: Sets the rounding mode @var{mode}.
        !          1166: @end table
        !          1167:
        !          1168: @table @var
        !          1169: @item return
        !          1170: \JP $B@0?t(B
        !          1171: \EG integer
        !          1172: @item mode
        !          1173: \JP $B@0?t(B
        !          1174: \EG integer
        !          1175: @end table
        !          1176:
        !          1177: @itemize @bullet
        !          1178: \BJP
        !          1179: @item
        !          1180: $B0z?t$,$"$k>l9g(B, @b{bigfloat} $B$N4]$a%b!<%I$r(B @var{mode} $B$K@_Dj$9$k(B.
        !          1181: $B0z?t$N$"$k$J$7$K$+$+$o$i$:(B, $B0JA0$K@_Dj$5$l$F$$$?CM$rJV$9(B.
        !          1182: $B4]$a%b!<%I$N0UL#$O<!$N$H$*$j(B.
        !          1183: @table @code
        !          1184: @item 0
        !          1185: Round to nearest
        !          1186: @item 1
        !          1187: Round toward 0
        !          1188: @item 2
        !          1189: Round toward +infinity
        !          1190: @item 3
        !          1191: Round toward -infinity
        !          1192: @end table
        !          1193: @item
        !          1194: @b{bigfloat} $B$G$N7W;;$KBP$7M-8z$G$"$k(B.
        !          1195: @b{bigfloat} $B$N(B flag $B$r(B on $B$K$9$kJ}K!$O(B, @code{ctrl} $B$r;2>H(B.
        !          1196: \E
        !          1197: \BEG
        !          1198: @item
        !          1199: When an argument @var{mode} is given, these functions
        !          1200: set the rounding mode for @b{bigfloat} operations to @var{mode}.
        !          1201: The return value is always the previous rounding mode regardless of
        !          1202: the existence of an argument.
        !          1203: The meanings of rounding modes are as follows
        !          1204: @table @code
        !          1205: @item 0
        !          1206: Round to nearest
        !          1207: @item 1
        !          1208: Round toward 0
        !          1209: @item 2
        !          1210: Round toward +infinity
        !          1211: @item 3
        !          1212: Round toward -infinity
        !          1213: @end table
        !          1214:
        !          1215: @item
        !          1216: This is effective for computations in @b{bigfloat}.
        !          1217: Refer to @code{ctrl()} for turning on the `@b{bigfloat} flag.'
        !          1218: \E
        !          1219: @end itemize
        !          1220:
        !          1221: @example
        !          1222: [1] setprec();
        !          1223: 15
1.1       noro     1224: [2] setprec(100);
1.11    ! noro     1225: 15
1.1       noro     1226: [3] setprec(100);
1.11    ! noro     1227: 99
        !          1228: [4] setbprec();
        !          1229: 332
1.1       noro     1230: @end example
                   1231:
                   1232: @table @t
1.2       noro     1233: \JP @item $B;2>H(B
1.11    ! noro     1234: @fref{ctrl}, @fref{eval deval}.
1.1       noro     1235: @end table
                   1236:
1.11    ! noro     1237:
1.2       noro     1238: \JP @node setmod,,, $B?t$N1i;;(B
                   1239: \EG @node setmod,,, Numbers
1.1       noro     1240: @subsection @code{setmod}
                   1241: @findex setmod
                   1242:
                   1243: @table @t
                   1244: @item setmod([@var{p}])
1.2       noro     1245: \JP :: $BM-8BBN$r(B GF(@var{p}) $B$K@_Dj$9$k(B.
                   1246: \EG :: Sets the ground field to GF(@var{p}).
1.1       noro     1247: @end table
                   1248:
                   1249: @table @var
                   1250: @item return
1.2       noro     1251: \JP $B@0?t(B
                   1252: \EG integer
1.1       noro     1253: @item n
1.2       noro     1254: \JP 2^27 $BL$K~$NAG?t(B
                   1255: \EG prime less than 2^27
1.1       noro     1256: @end table
                   1257:
                   1258: @itemize @bullet
1.2       noro     1259: \BJP
1.1       noro     1260: @item
                   1261: $BM-8BBN$r(B GF(@var{p}) $B$K@_Dj$9$k(B. $B@_DjCM$rJV$9(B.
                   1262: @item
                   1263: $BM-8BBN$N85$N7?$r;}$D?t$O(B, $B$=$l<+?H$O$I$NM-8BBN$KB0$9$k$+$N>pJs$r;}$?$:(B,
                   1264: $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     1265: @item
                   1266: $B0L?t$NBg$-$JM-8BBN$K4X$7$F$O(B @pxref{$BM-8BBN$K4X$9$k1i;;(B}.
                   1267: \E
                   1268: \BEG
                   1269: @item
                   1270: Sets the ground field to GF(@var{p}) and returns the value @var{p}.
                   1271: @item
                   1272: A member of a finite field does not have any information
                   1273: about the field and the arithmetic operations over GF(@var{p}) are applied
                   1274: with @var{p} set at the time.
                   1275: @item
                   1276: As for large finite fields, @pxref{Finite fields}.
                   1277: \E
1.1       noro     1278: @end itemize
                   1279:
                   1280: @example
                   1281: [0] A=dp_mod(dp_ptod(2*x,[x]),3,[]);
                   1282: (2)*<<1>>
                   1283: [1] A+A;
                   1284: addmi : invalid modulus
                   1285: return to toplevel
                   1286: [1] setmod(3);
                   1287: 3
                   1288: [2] A+A;
                   1289: (1)*<<1>>
                   1290: @end example
                   1291:
                   1292: @table @t
1.2       noro     1293: \JP @item $B;2>H(B
                   1294: \EG @item References
                   1295: \JP @fref{dp_mod dp_rat}, @fref{$B?t$N7?(B}.
                   1296: \EG @fref{dp_mod dp_rat}, @fref{Types of numbers}.
1.1       noro     1297: @end table
                   1298:
1.3       noro     1299: \JP @node ntoint32 int32ton,,, $B?t$N1i;;(B
                   1300: \EG @node ntoint32 int32ton,,, Numbers
                   1301: @subsection @code{ntoint32}, @code{int32ton}
                   1302: @findex ntoint32
                   1303: @findex int32ton
                   1304:
                   1305: @table @t
                   1306: @item ntoint32(@var{n})
                   1307: @itemx int32ton(@var{int32})
                   1308: \JP :: $BHsIi@0?t$HId9f$J$7(B 32bit $B@0?t$N4V$N7?JQ49(B.
                   1309: \EG :: Type-conversion between a non-negative integer and an unsigned 32bit integer.
                   1310: @end table
                   1311:
                   1312: @table @var
                   1313: @item return
                   1314: \JP $BId9f$J$7(B 32bit $B@0?t$^$?$OHsIi@0?t(B
                   1315: \EG unsigned 32bit integer or non-negative integer
                   1316: @item n
                   1317: \JP 2^32 $BL$K~$NHsIi@0?t(B
                   1318: \EG non-negative interger less than 2^32
                   1319: @item int32
                   1320: \JP $BId9f$J$7(B 32bit $B@0?t(B
                   1321: \EG unsigned 32bit integer
                   1322: @end table
                   1323:
                   1324: @itemize @bullet
                   1325: \BJP
                   1326: @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,
                   1327: $B$^$?$O$=$N5UJQ49$r9T$&(B.
                   1328: @item 32bit $B@0?t$O(B @b{OpenXM} $B$N4pK\9=@.MWAG$G$"$j(B, $B@0?t$r$=$N7?$GAw?.(B
                   1329: $B$9$kI,MW$,$"$k>l9g$KMQ$$$k(B.
                   1330: \E
                   1331: \BEG
                   1332: @item These functions do conversions between non-negative
                   1333: integers (the type id 1) and unsigned 32bit integers (the type id 10).
                   1334: @item An unsigned 32bit integer is a fundamental construct of @b{OpenXM}
                   1335: and one often has to send an integer to a server as an unsigned 32bit
                   1336: integer. These functions are used in such a case.
                   1337: \E
                   1338: @end itemize
                   1339:
                   1340: @table @t
                   1341: \JP @item $B;2>H(B
                   1342: \EG @item References
                   1343: \JP @fref{$BJ,;67W;;(B}, @fref{$B?t$N7?(B}.
                   1344: \EG @fref{Distributed computation}, @fref{Types of numbers}.
                   1345: @end table

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