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

1.14    ! takayama    1: @comment $OpenXM: OpenXM/src/asir-doc/parts/builtin/num.texi,v 1.13 2019/03/29 01:57:46 noro 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::
1.12      noro       25: * setbprec setprec::
1.1       noro       26: * setmod::
                     27: * lrandom::
1.3       noro       28: * ntoint32 int32ton::
1.12      noro       29: * setround::
1.13      noro       30: * inttorat::
1.1       noro       31: @end menu
                     32:
1.2       noro       33: \JP @node idiv irem,,, $B?t$N1i;;(B
                     34: \EG @node idiv irem,,, Numbers
1.1       noro       35: @subsection @code{idiv}, @code{irem}
                     36: @findex idiv
                     37: @findex irem
                     38:
                     39: @table @t
                     40: @item idiv(@var{i1},@var{i2})
1.2       noro       41: \JP :: $B@0?t=|;;$K$h$k>&(B.
                     42: \EG :: Integer quotient of @var{i1} divided by @var{i2}.
1.1       noro       43: @item irem(@var{i1},@var{i2})
1.2       noro       44: \JP :: $B@0?t=|;;$K$h$k>jM>(B.
                     45: \EG :: Integer remainder of @var{i1} divided by @var{i2}.
1.1       noro       46: @end table
                     47:
                     48: @table @var
                     49: @item return
1.2       noro       50: \JP $B@0?t(B
                     51: \EG integer
1.8       noro       52: @item i1 i2
1.2       noro       53: \JP $B@0?t(B
                     54: \EG integer
1.1       noro       55: @end table
                     56:
                     57: @itemize @bullet
1.2       noro       58: \BJP
1.1       noro       59: @item
                     60: @var{i1} $B$N(B @var{i2} $B$K$h$k@0?t=|;;$K$h$k>&(B, $B>jM>$r5a$a$k(B.
                     61: @item
                     62: @var{i2} $B$O(B 0 $B$G$"$C$F$O$J$i$J$$(B.
                     63: @item
                     64: $BHo=|?t$,Ii$N>l9g(B, $B@dBPCM$KBP$9$kCM$K%^%$%J%9$r$D$1$?CM$rJV$9(B.
                     65: @item
                     66: @var{i1} @code{%} @var{i2} $B$O(B, $B7k2L$,@5$K@55,2=$5$l$k$3$H$r=|$1$P(B
                     67: @code{irem()} $B$NBe$o$j$KMQ$$$k$3$H$,$G$-$k(B.
                     68: @item
                     69: $BB?9`<0$N>l9g$O(B @code{sdiv}, @code{srem} $B$rMQ$$$k(B.
1.2       noro       70: \E
                     71: \BEG
                     72: @item
                     73: Integer quotient and remainder of @var{i1} divided by @var{i2}.
                     74: @item
                     75: @var{i2} must not be 0.
                     76: @item
                     77: If the dividend is negative, the results are obtained by changing the
                     78: sign of the results for absolute values of the dividend.
                     79: @item
                     80: One can use
                     81: @var{i1} @code{%} @var{i2}
                     82: for replacement of @code{irem()} which only differs in the point that
                     83: the result is always normalized to non-negative values.
                     84: @item
                     85: Use @code{sdiv()}, @code{srem()} for polynomial quotient.
                     86: \E
1.1       noro       87: @end itemize
                     88:
                     89: @example
                     90: [0] idiv(100,7);
                     91: 14
                     92: [0] idiv(-100,7);
                     93: -14
                     94: [1] irem(100,7);
                     95: 2
                     96: [1] irem(-100,7);
                     97: -2
                     98: @end example
                     99:
                    100: @table @t
1.2       noro      101: \JP @item $B;2>H(B
                    102: \EG @item References
1.1       noro      103: @fref{sdiv sdivm srem sremm sqr sqrm}, @fref{%}.
                    104: @end table
                    105:
1.2       noro      106: \JP @node fac,,, $B?t$N1i;;(B
                    107: \EG @node fac,,, Numbers
1.1       noro      108: @subsection @code{fac}
                    109: @findex fac
                    110:
                    111: @table @t
                    112: @item fac(@var{i})
1.2       noro      113: \JP :: @var{i} $B$N3,>h(B.
                    114: \EG :: The factorial of @var{i}.
1.1       noro      115: @end table
                    116:
                    117: @table @var
                    118: @item return
1.2       noro      119: \JP $B@0?t(B
                    120: \EG integer
1.1       noro      121: @item i
1.2       noro      122: \JP $B@0?t(B
                    123: \EG integer
1.1       noro      124: @end table
                    125:
                    126: @itemize @bullet
1.2       noro      127: \BJP
1.1       noro      128: @item
                    129: @var{i} $B$N3,>h$r7W;;$9$k(B.
                    130: @item
                    131: @var{i} $B$,Ii$N>l9g$O(B 0 $B$rJV$9(B.
1.2       noro      132: \E
                    133: \BEG
                    134: @item
                    135: The factorial of @var{i}.
                    136: @item
                    137: Returns 0 if the argument @var{i} is negative.
                    138: \E
1.1       noro      139: @end itemize
                    140:
                    141: @example
                    142: [0] fac(50);
                    143: 30414093201713378043612608166064768844377641568960512000000000000
                    144: @end example
                    145:
1.2       noro      146: \JP @node igcd igcdcntl,,, $B?t$N1i;;(B
                    147: \EG @node igcd igcdcntl,,, Numbers
1.1       noro      148: @subsection @code{igcd},@code{igcdcntl}
                    149: @findex igcd
                    150: @findex igcdcntl
                    151:
                    152: @table @t
                    153: @item igcd(@var{i1},@var{i2})
1.2       noro      154: \JP :: $B@0?t$N(B GCD ($B:GBg8xLs?t(B)
                    155: \EG :: The integer greatest common divisor of @var{i1} and @var{i2}.
1.1       noro      156: @item igcdcntl([@var{i}])
1.2       noro      157: \JP :: $B@0?t(B GCD$B$N%"%k%4%j%:%`A*Br(B
                    158: \EG :: Selects an algorithm for integer GCD.
1.1       noro      159: @end table
                    160:
                    161: @table @var
                    162: @item return
1.2       noro      163: \JP $B@0?t(B
                    164: \EG integer
1.8       noro      165: @item i1 i2 i
1.2       noro      166: \JP $B@0?t(B
                    167: \EG integer
1.1       noro      168: @end table
                    169:
                    170: @itemize @bullet
1.2       noro      171: \BJP
1.1       noro      172: @item
                    173: @code{igcd} $B$O(B @var{i1} $B$H(B @var{i2} $B$N(B GCD $B$r5a$a$k(B.
                    174: @item
                    175: $B0z?t$,@0?t$G$J$$>l9g$O(B, $B%(%i!<$^$?$OL50UL#$J7k2L$rJV$9(B.
                    176: @item
                    177: $BB?9`<0$N>l9g$O(B, @code{gcd}, @code{gcdz} $B$rMQ$$$k(B.
                    178: @item
                    179: $B@0?t(B GCD $B$K$O$5$^$6$^$JJ}K!$,$"$j(B, @code{igcdcntl} $B$G@_Dj$G$-$k(B.
                    180:
                    181: @table @code
                    182: @item 0
                    183: Euclid $B8_=|K!(B (default)
                    184: @item 1
                    185: binary GCD
                    186: @item 2
                    187: bmod GCD
                    188: @item 3
                    189: accelerated integer GCD
                    190: @end table
1.2       noro      191: @code{2}, @code{3} $B$O(B @code{[Weber]} $B$K$h$k(B.
1.1       noro      192:
1.2       noro      193: $B$*$*$`$M(B @code{3} $B$,9bB.$@$,(B, $BNc30$b$"$k(B.
                    194: \E
                    195: \BEG
                    196: @item
                    197: Function @code{igcd()} returns the integer greatest common divisor of
                    198: the given two integers.
                    199: @item
                    200: An error will result if the argument is not an integer; the result is
                    201: not valid even if one is returned.
                    202: @item
                    203: Use @code{gcd()}, @code{gcdz()} for polynomial GCD.
                    204:
                    205: @item
                    206: Various method of integer GCD computation are implemented
                    207: and they can be selected by @code{igcdcntl}.
                    208:
                    209: @table @code
                    210: @item 0
                    211: Euclid algorithm (default)
                    212: @item 1
                    213: binary GCD
                    214: @item 2
                    215: bmod GCD
                    216: @item 3
                    217: accelerated integer GCD
                    218: @end table
                    219: @code{2}, @code{3} are due to @code{[Weber]}.
                    220:
                    221: In most cases @code{3} is the fastest, but there are exceptions.
                    222: \E
1.1       noro      223: @end itemize
                    224:
                    225: @example
                    226: [0] A=lrandom(10^4)$
                    227: [1] B=lrandom(10^4)$
                    228: [2] C=lrandom(10^4)$
                    229: [3] D=A*C$
                    230: [4] E=A*B$
                    231: [5] cputime(1)$
                    232: [6] igcd(D,E)$
                    233: 0.6sec + gc : 1.93sec(2.531sec)
                    234: [7] igcdcntl(1)$
                    235: [8] igcd(D,E)$
                    236: 0.27sec(0.2635sec)
                    237: [9] igcdcntl(2)$
                    238: [10] igcd(D,E)$
                    239: 0.19sec(0.1928sec)
                    240: [11] igcdcntl(3)$
                    241: [12] igcd(D,E)$
                    242: 0.08sec(0.08023sec)
                    243: @end example
                    244:
                    245: @table @t
1.2       noro      246: \JP @item $B;2>H(B
                    247: \EG @item References
1.1       noro      248: @fref{gcd gcdz}.
                    249: @end table
                    250:
1.2       noro      251: \JP @node ilcm,,, $B?t$N1i;;(B
                    252: \EG @node ilcm,,, Numbers
1.1       noro      253: @subsection @code{ilcm}
                    254: @findex ilcm
                    255:
                    256: @table @t
                    257: @item ilcm(@var{i1},@var{i2})
1.2       noro      258: \JP :: $B:G>.8xG\?t$r5a$a$k(B.
                    259: \EG :: The integer least common multiple of @var{i1} and @var{i2}.
1.1       noro      260: @end table
                    261:
                    262: @table @var
                    263: @item return
1.2       noro      264: \JP $B@0?t(B
                    265: \EG integer
1.8       noro      266: @item i1 i2
1.2       noro      267: \JP $B@0?t(B
                    268: \EG integer
1.1       noro      269: @end table
                    270:
                    271: @itemize @bullet
1.2       noro      272: \BJP
1.1       noro      273: @item
                    274: $B@0?t(B @var{i1}, @var{i2} $B$N:G>.8xG\?t$r5a$a$k(B.
                    275: @item
                    276: $B0lJ}$,(B 0 $B$N>l9g(B 0 $B$rJV$9(B.
1.2       noro      277: \E
                    278: \BEG
1.1       noro      279: @item
1.2       noro      280: This function computes the integer least common multiple of
                    281: @var{i1}, @var{i2}.
                    282: @item
                    283: If one of argument is equal to 0, the return 0.
                    284: \E
1.1       noro      285: @end itemize
                    286:
                    287: @table @t
1.2       noro      288: \JP @item $B;2>H(B
                    289: \EG @item References
1.1       noro      290: @fref{igcd igcdcntl}, @fref{mt_save mt_load}.
1.9       ohara     291: @end table
                    292:
                    293: \JP @node isqrt,,, $B?t$N1i;;(B
                    294: \EG @node isqrt,,, Numbers
                    295: @subsection @code{isqrt}
                    296: @findex isqrt
                    297:
                    298: @table @t
                    299: @item isqrt(@var{n})
                    300: \JP :: $BJ?J}:,$r1[$($J$$:GBg$N@0?t$r5a$a$k(B.
                    301: \EG :: The integer square root of @var{n}.
                    302: @end table
                    303:
                    304: @table @var
                    305: @item return
                    306: \JP $BHsIi@0?t(B
                    307: \EG non-negative integer
                    308: @item n
                    309: \JP $BHsIi@0?t(B
                    310: \EG non-negative integer
1.1       noro      311: @end table
1.2       noro      312:
                    313: \JP @node inv,,, $B?t$N1i;;(B
                    314: \EG @node inv,,, Numbers
1.1       noro      315: @subsection @code{inv}
                    316: @findex inv
                    317:
                    318: @table @t
                    319: @item inv(@var{i},@var{m})
1.2       noro      320: \JP :: @var{m} $B$rK!$H$9$k(B @var{i} $B$N5U?t(B
                    321: \EG :: the inverse (reciprocal) of @var{i} modulo @var{m}.
1.1       noro      322: @end table
                    323:
                    324: @table @var
                    325: @item return
1.2       noro      326: \JP $B@0?t(B
                    327: \EG integer
1.8       noro      328: @item i m
1.2       noro      329: \JP $B@0?t(B
                    330: \EG integer
1.1       noro      331: @end table
                    332:
                    333: @itemize @bullet
1.2       noro      334: \BJP
1.1       noro      335: @item
                    336: @var{ia} @equiv{} 1 mod (@var{m}) $B$J$k@0?t(B @var{a} $B$r5a$a$k(B.
                    337: @item
                    338: @var{i} $B$H(B @var{m} $B$O8_$$$KAG$G$J$1$l$P$J$i$J$$$,(B, @code{inv()} $B$O(B
                    339: $B$=$N%A%'%C%/$O9T$o$J$$(B.
1.2       noro      340: \E
                    341: \BEG
                    342: @item
                    343: This function computes an integer such that
                    344: @var{ia} @equiv{} 1 mod (@var{m}).
                    345: @item
                    346: The integer @var{i} and  @var{m} must be mutually prime.
                    347: However, @code{inv()} does not check it.
                    348: \E
1.1       noro      349: @end itemize
                    350:
                    351: @example
                    352: [71] igcd(1234,4321);
                    353: 1
                    354: [72] inv(1234,4321);
                    355: 3239
                    356: [73] irem(3239*1234,4321);
                    357: 1
                    358: @end example
                    359:
                    360: @table @t
1.2       noro      361: \JP @item $B;2>H(B
                    362: \EG @item References
1.1       noro      363: @fref{igcd igcdcntl}.
                    364: @end table
                    365:
1.2       noro      366: \JP @node prime lprime,,, $B?t$N1i;;(B
                    367: \EG @node prime lprime,,, Numbers
1.1       noro      368: @subsection @code{prime}, @code{lprime}
                    369: @findex prime
                    370: @findex lprime
                    371:
                    372: @table @t
                    373: @item prime(@var{index})
                    374: @item lprime(@var{index})
1.2       noro      375: \JP :: $BAG?t$rJV$9(B
                    376: \EG :: Returns a prime number.
1.1       noro      377: @end table
                    378:
                    379: @table @var
                    380: @item return
1.2       noro      381: \JP $B@0?t(B
                    382: \EG integer
1.1       noro      383: @item index
1.2       noro      384: \JP $B@0?t(B
                    385: \EG integer
1.1       noro      386: @end table
                    387:
                    388: @itemize @bullet
1.2       noro      389: \BJP
1.1       noro      390: @item
                    391: @code{prime()}, @code{lprime()} $B$$$:$l$b%7%9%F%`$,FbIt$K;}$D(B
                    392: $BAG?tI=$NMWAG$rJV$9(B. @code{index} $B$O(B 0 $B0J>e$N@0?t$G(B, $BAG?tI=(B
                    393: $B$N%$%s%G%C%/%9$KMQ$$$i$l$k(B. @code{prime()} $B$O(B 16381 $B$^$G(B
                    394: $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
                    395: $BAG?t$+$iBg$-$$=g$K(B 999 $B8DJV$9(B. $B$=$l0J30$N%$%s%G%C%/%9$KBP$7$F$O(B
                    396: 0 $B$rJV$9(B.
                    397: @item
1.2       noro      398: $B$h$j0lHLE*$JAG?t@8@.H!?t$H$7$F$O(B,
                    399: @code{pari(nextprime,@var{number})}
1.1       noro      400: $B$,$"$k(B.
1.2       noro      401: \E
                    402: \BEG
                    403: @item
                    404: The two functions, @code{prime()} and @code{lprime()}, returns
                    405: an element stored in the system table of prime numbers.
                    406: Here, @code{index} is a non-negative integer and be used as an index
                    407: for the prime tables.
                    408: The function @code{prime()} can return one of 1900 primes
                    409: up to 16381 indexed so that the smaller one has smaller
                    410: index.  The function @code{lprime()} can return one of 999 primes which
                    411: are 8 digit sized and indexed so that the larger one has the smaller
                    412: index.
                    413: The two function always returns 0 for other indices.
                    414: @item
                    415: For more general function for prime generation, there is a @code{PARI}
                    416: function
                    417:
                    418: @code{pari(nextprime,@var{number})}.
                    419: \E
1.1       noro      420: @end itemize
                    421:
                    422: @example
                    423: [95] prime(0);
                    424: 2
                    425: [96] prime(1228);
                    426: 9973
                    427: [97] lprime(0);
                    428: 99999989
                    429: [98] lprime(999);
                    430: 0
                    431: @end example
                    432:
                    433: @table @t
1.2       noro      434: \JP @item $B;2>H(B
                    435: \EG @item References
1.1       noro      436: @fref{pari}.
                    437: @end table
                    438:
1.2       noro      439: \JP @node random,,, $B?t$N1i;;(B
                    440: \EG @node random,,, Numbers
1.1       noro      441: @subsection @code{random}
                    442: @findex random
                    443:
                    444: @table @t
1.5       takayama  445: @item random([@var{seed}])
1.2       noro      446: \JP :: $BMp?t$r@8@.$9$k(B.
1.1       noro      447: @end table
                    448:
                    449: @table @var
                    450: @item seed
1.2       noro      451: @itemx return
                    452: \JP $B<+A3?t(B
                    453: \EG non-negative integer
1.1       noro      454: @end table
                    455:
                    456: @itemize @bullet
1.2       noro      457: \BJP
1.1       noro      458: @item
                    459: $B:GBg(B 2^32-1 $B$NHsIi@0?t$NMp?t$r@8@.$9$k(B.
                    460: @item
                    461: 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.
                    462: @item
                    463: 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
                    464: $B7ONs$O5/F0Kh$K0lDj$G$"$k(B.
                    465: @item
                    466: $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.
                    467: @item
                    468: $B<~4|$O(B 2^19937-1 $B$HHs>o$KD9$$(B.
                    469: @item
                    470: @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}
                    471: $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
                    472: $B$G$-$k(B.
1.2       noro      473: \E
                    474: \BEG
                    475: @item
                    476: Generates a random number which is a non-negative integer less than 2^32.
                    477: @item
                    478: If a non zero argument is specified, then after setting it as a random seed,
                    479: a random number is generated.
                    480: @item
                    481: As the default seed is fixed, the sequence of the random numbers is
                    482: always the same if a seed is not set.
                    483: @item
                    484: The algorithm is Mersenne Twister
                    485: (http://www.math.keio.ac.jp/matsumoto/mt.html) by M. Matsumoto and
                    486: T. Nishimura. The implementation is done also by themselves.
                    487: @item
                    488: The period of the random number sequence is 2^19937-1.
                    489: @item
                    490: One can save the state of the random number generator with @code{mt_save}.
                    491: By loading the state file with @code{mt_load},
                    492: one can trace a single random number sequence arcoss multiple sessions.
                    493: \E
1.1       noro      494: @end itemize
                    495:
                    496: @table @t
1.2       noro      497: \JP @item $B;2>H(B
                    498: \EG @item References
1.1       noro      499: @fref{lrandom}, @fref{mt_save mt_load}.
                    500: @end table
                    501:
1.2       noro      502: \JP @node lrandom,,, $B?t$N1i;;(B
                    503: \EG @node lrandom,,, Numbers
1.1       noro      504: @subsection @code{lrandom}
                    505: @findex lrandom
                    506:
                    507: @table @t
1.5       takayama  508: @item lrandom(@var{bit})
1.2       noro      509: \JP :: $BB?G\D9Mp?t$r@8@.$9$k(B.
                    510: \EG :: Generates a long random number.
1.1       noro      511: @end table
                    512:
                    513: @table @var
                    514: @item bit
                    515: @item return
1.2       noro      516: \JP $B<+A3?t(B
                    517: \EG integer
1.1       noro      518: @end table
                    519:
                    520: @itemize @bullet
1.2       noro      521: \BJP
1.1       noro      522: @item
                    523: $B9b!9(B @var{bit} $B$NHsIi@0?t$NMp?t$r@8@.$9$k(B.
                    524: @item
                    525: @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      526: \E
                    527: \BEG
                    528: @item
                    529: Generates a non-negative integer of at most @var{bit} bits.
                    530: @item
                    531: The result is a concatination of outputs of @code{random}.
                    532: \E
1.1       noro      533: @end itemize
                    534:
                    535: @table @t
1.2       noro      536: \JP @item $B;2>H(B
                    537: \EG @item References
1.1       noro      538: @fref{random}, @fref{mt_save mt_load}.
                    539: @end table
                    540:
1.2       noro      541: \JP @node mt_save mt_load,,, $B?t$N1i;;(B
                    542: \EG @node mt_save mt_load,,, Numbers
1.1       noro      543: @subsection @code{mt_save}, @code{mt_load}
                    544: @findex mt_save
                    545: @findex mt_load
                    546:
                    547: @table @t
                    548: @item mt_save(@var{fname})
1.2       noro      549: \JP :: $BMp?t@8@.4o$N8=:_$N>uBV$r%U%!%$%k$K%;!<%V$9$k(B.
                    550: \EG :: Saves the state of the random number generator.
1.1       noro      551: @item mt_load(@var{fname})
1.2       noro      552: \JP :: $B%U%!%$%k$K%;!<%V$5$l$?Mp?t@8@.4o$N>uBV$r%m!<%I$9$k(B.
                    553: \EG :: Loads a saved state of the random number generator.
1.1       noro      554: @end table
                    555:
                    556: @table @var
                    557: @item return
1.2       noro      558: \JP 0 $B$^$?$O(B 1
                    559: \EG 0 or 1
1.1       noro      560: @item fname
1.2       noro      561: \JP $BJ8;zNs(B
                    562: \EG string
1.1       noro      563: @end table
                    564:
                    565: @itemize @bullet
1.2       noro      566: \BJP
                    567: @item
                    568: $B$"$k>uBV$r%;!<%V$7(B, $B$=$N>uBV$r%m!<%I$9$k$3$H$G(B,
1.1       noro      569: $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
                    570: $B$G$-$k(B.
1.2       noro      571: \E
                    572: \BEG
                    573: @item
                    574: One can save the state of the random number generator with @code{mt_save}.
                    575: By loading the state file with @code{mt_load},
                    576: one can trace a single random number sequence arcoss multiple
                    577: @b{Asir} sessions.
                    578: \E
1.1       noro      579: @end itemize
                    580:
                    581: @example
                    582: [340] random();
                    583: 3510405877
                    584: [341] mt_save("/tmp/mt_state");
                    585: 1
                    586: [342] random();
                    587: 4290933890
                    588: [343] quit;
                    589: % asir
                    590: This is Asir, Version 991108.
                    591: Copyright (C) FUJITSU LABORATORIES LIMITED.
                    592: 3 March 1994. All rights reserved.
                    593: [340] mt_load("/tmp/mt_state");
                    594: 1
                    595: [341] random();
                    596: 4290933890
                    597: @end example
                    598:
                    599: @table @t
1.2       noro      600: \JP @item $B;2>H(B
                    601: \EG @item References
1.1       noro      602: @fref{random}, @fref{lrandom}.
                    603: @end table
                    604:
1.2       noro      605: \JP @node nm dn,,, $B?t$N1i;;(B
                    606: \EG @node nm dn,,, Numbers
1.1       noro      607: @subsection @code{nm}, @code{dn}
                    608: @findex nm
                    609: @findex dn
                    610:
                    611: @table @t
                    612: @item nm(@var{rat})
1.2       noro      613: \JP :: @var{rat} $B$NJ,;R(B.
                    614: \EG :: Numerator of @var{rat}.
1.1       noro      615: @item dn(@var{rat})
1.2       noro      616: \JP :: @var{rat} $B$NJ,Jl(B.
                    617: \EG :: Denominator of @var{rat}.
1.1       noro      618: @end table
                    619:
                    620: @table @var
                    621: @item return
1.2       noro      622: \JP $B@0?t$^$?$OB?9`<0(B
                    623: \EG integer or polynomial
1.1       noro      624: @item rat
1.2       noro      625: \JP $BM-M}?t$^$?$OM-M}<0(B
                    626: \EG rational number or rational expression
1.1       noro      627: @end table
                    628:
                    629: @itemize @bullet
1.2       noro      630: \BJP
1.1       noro      631: @item
                    632: $BM?$($i$l$?M-M}?t$^$?M-M}<0$NJ,;R5Z$SJ,Jl$rJV$9(B.
                    633: @item
                    634: $BM-M}?t$N>l9g(B, $BJ,Jl$O>o$K@5$G(B, $BId9f$OJ,;R$,;}$D(B.
                    635: @item
                    636: $BM-M}<0$N>l9g(B, $BC1$KJ,Jl(B, $BJ,;R$r<h$j=P$9$@$1$G$"$k(B.
                    637: $BM-M}<0$KBP$7$F$O(B, $BLsJ,$O<+F0E*$K$O9T$o$l$J$$(B. @code{red()}
                    638: $B$rL@<(E*$K8F$S=P$9I,MW$,$"$k(B.
1.2       noro      639: \E
                    640: \BEG
                    641: @item
                    642: Numerator and denominator of a given rational expression.
                    643: @item
                    644: For a rational number, they return its numerator and denominator,
                    645: respectively.  For a rational expression whose numerator and denominator
                    646: may contain rational numbers, they do not separate those rational
                    647: coefficients to numerators and denominators.
                    648: @item
                    649: For a rational number, the denominator is always kept positive, and
                    650: the sign is contained in the numerator.
                    651: @item
                    652: @b{Risa/Asir} does not cancel the common divisors unless otherwise explicitly
                    653: specified by the user.
                    654: Therefore, @code{nm()} and @code{dn()} return the numerator and the
                    655: denominator as it is, respectively.
                    656: \E
1.1       noro      657: @end itemize
                    658:
                    659: @example
                    660: [2] [nm(-43/8),dn(-43/8)];
                    661: [-43,8]
                    662: [3] dn((x*z)/(x*y));
                    663: y*x
                    664: [3] dn(red((x*z)/(x*y)));
                    665: y
                    666: @end example
                    667:
                    668: @table @t
1.2       noro      669: \JP @item $B;2>H(B
                    670: \EG @item References
1.1       noro      671: @fref{red}.
                    672: @end table
                    673:
1.2       noro      674: \JP @node conj real imag,,, $B?t$N1i;;(B
                    675: \EG @node conj real imag,,, Numbers
1.1       noro      676: @subsection @code{conj}, @code{real}, @code{imag}
                    677: @findex conj
                    678:
                    679: @table @t
                    680: @item real(@var{comp})
1.2       noro      681: \JP :: @var{comp} $B$N<B?tItJ,(B.
                    682: \EG :: Real part of @var{comp}.
1.1       noro      683: @item imag(@var{comp})
1.2       noro      684: \JP :: @var{comp} $B$N5u?tItJ,(B.
                    685: \EG :: Imaginary part of @var{comp}.
1.1       noro      686: @item conj(@var{comp})
1.2       noro      687: \JP :: @var{comp} $B$N6&LrJ#AG?t(B.
                    688: \EG :: Complex conjugate of @var{comp}.
1.1       noro      689: @end table
                    690:
                    691: @table @var
                    692: @item return comp
1.2       noro      693: \JP $BJ#AG?t(B
                    694: \EG complex number
1.1       noro      695: @end table
                    696:
                    697: @itemize @bullet
1.2       noro      698: \BJP
1.1       noro      699: @item
                    700: $BJ#AG?t$KBP$7(B, $B<BIt(B, $B5uIt(B, $B6&Lr$r5a$a$k(B.
                    701: @item
                    702: $B$3$l$i$O(B, $BB?9`<0$KBP$7$F$bF/$/(B.
1.2       noro      703: \E
                    704: \BEG
                    705: @item
                    706: Basic operations for complex numbers.
                    707: @item
                    708: These functions works also for polynomials with complex coefficients.
                    709: \E
1.1       noro      710: @end itemize
                    711:
                    712: @example
                    713: [111] A=(2+@@i)^3;
                    714: (2+11*@@i)
                    715: [112] [real(A),imag(A),conj(A)];
                    716: [2,11,(2-11*@@i)]
                    717: @end example
                    718:
1.4       noro      719: \JP @node eval deval ,,, $B?t$N1i;;(B
                    720: \EG @node eval deval,,, Numbers
                    721: @subsection @code{eval}, @code{deval}
1.1       noro      722: @findex eval
1.4       noro      723: @findex deval
1.1       noro      724: @cindex PARI
                    725:
                    726: @table @t
                    727: @item eval(@var{obj}[,@var{prec}])
1.4       noro      728: @item deval(@var{obj})
1.2       noro      729: \JP :: @var{obj} $B$NCM$NI>2A(B.
                    730: \EG :: Evaluate @var{obj} numerically.
1.1       noro      731: @end table
                    732:
                    733: @table @var
                    734: @item return
1.2       noro      735: \JP $B?t$"$k$$$O<0(B
                    736: \EG number or expression
1.1       noro      737: @item obj
1.2       noro      738: \JP $B0lHL$N<0(B
                    739: \EG general expression
1.1       noro      740: @item prec
1.2       noro      741: \JP $B@0?t(B
                    742: \EG integer
1.1       noro      743: @end table
                    744:
                    745: @itemize @bullet
1.2       noro      746: \BJP
1.1       noro      747: @item
                    748: @var{obj} $B$K4^$^$l$kH!?t$NCM$r2DG=$J8B$jI>2A$9$k(B.
                    749: @item
1.4       noro      750: @code{deval} $B$OG\@:EYIbF0>.?t$r7k2L$H$7$F(B
                    751: @code{eval} $B$N>l9g(B, $BM-M}?t$O$=$N$^$^;D$k(B.
1.1       noro      752: @item
1.11      noro      753: @code{eval} $B$K$*$$$F$O(B, $B7W;;$O(B @b{MPFR} $B%i%$%V%i%j$,9T$&(B.
1.4       noro      754: @code{deval} $B$K$*$$$F$O(B, $B7W;;$O(B C $B?t3X%i%$%V%i%j$N4X?t$rMQ$$$F9T$&(B.
                    755: @item
                    756: @code{deval} $B$OJ#AG?t$O07$($J$$(B.
                    757: @item
                    758: @code{eval} $B$K$*$$$F$O(B,
1.1       noro      759: @var{prec} $B$r;XDj$7$?>l9g(B, $B7W;;$O(B, 10 $B?J(B @var{prec} $B7eDxEY$G9T$o$l$k(B.
                    760: @var{prec} $B$N;XDj$,$J$$>l9g(B, $B8=:_@_Dj$5$l$F$$$k@:EY$G9T$o$l$k(B.
1.12      noro      761: (@xref{setbprec setprec}.)
1.1       noro      762: @item
                    763: @table @t
                    764: @item $B07$($kH!?t$O(B, $B<!$NDL$j(B.
                    765: @code{sin}, @code{cos}, @code{tan},
                    766:
                    767: @code{asin}, @code{acos}, @code{atan},
                    768:
                    769: @code{sinh}, @code{cosh}, @code{tanh},
                    770:
                    771: @code{asinh}, @code{acosh}, @code{atanh},
                    772:
                    773: @code{exp}, @code{log}, @code{pow(a,b) (a^b)}
                    774: @end table
                    775: @item
1.4       noro      776: $B0J2<$N5-9f$r?t$H$7$FI>2A$G$-$k(B. $B$?$@$7(B @code{@@i} $B$r07$($k$N$O(B
                    777: @code{eval}, @code{deval} $B$N$_$G$"$k(B.
1.1       noro      778: @table @t
                    779: @item @@i
                    780: $B5u?tC10L(B
                    781: @item @@pi
                    782: $B1_<~N((B
                    783: @item @@e
                    784: $B<+A3BP?t$NDl(B
                    785: @end table
1.2       noro      786: \E
                    787: \BEG
                    788: @item
                    789: Evaluates the value of the functions contained in @var{obj} as far as
                    790: possible.
                    791: @item
1.4       noro      792: @code{deval} returns
                    793: double float. Rational numbers remain unchanged in results from @code{eval}.
                    794: @item
                    795: In @code{eval} the computation is done
1.11      noro      796: by @b{MPFR} library. In @code{deval} the computation is
1.4       noro      797: done by the C math library.
                    798: @item
                    799: @code{deval} cannot handle complex numbers.
1.2       noro      800: @item
                    801: When @var{prec} is specified, computation will be performed with a
                    802: precision of about @var{prec}-digits.
                    803: If @var{prec} is not specified, computation is performed with the
1.12      noro      804: precision set currently. (@xref{setbprec setprec}.)
1.2       noro      805: @item
                    806: Currently available numerical functions are listed below.
                    807:
                    808: @table @t
                    809: @code{sin}, @code{cos}, @code{tan},
                    810:
                    811: @code{asin}, @code{acos}, @code{atan},
                    812:
                    813: @code{sinh}, @code{cosh}, @code{tanh},
                    814: @code{asinh}, @code{acosh}, @code{atanh},
                    815:
                    816: @code{exp}, @code{log}, @code{pow(a,b) (a^b)}
                    817: @end table
                    818: @item
1.4       noro      819: Symbols for special values are as the followings. Note that
                    820: @code{@@i} cannot be handled by @code{deval}.
1.2       noro      821: @table @t
                    822: @item @@i
                    823: unit of imaginary number
                    824: @item @@pi
                    825: the number pi,
                    826: the ratio of circumference to diameter
                    827: @item @@e
                    828: Napier's number (@t{exp}(1))
                    829: @end table
                    830: \E
1.1       noro      831: @end itemize
                    832:
                    833: @example
                    834: [118] eval(exp(@@pi*@@i));
                    835: -1.0000000000000000000000000000
                    836: [119] eval(2^(1/2));
                    837: 1.414213562373095048763788073031
                    838: [120] eval(sin(@@pi/3));
                    839: 0.86602540378443864674620506632
                    840: [121] eval(sin(@@pi/3)-3^(1/2)/2,50);
                    841: -2.78791084448179148471 E-58
1.4       noro      842: [122] eval(1/2);
                    843: 1/2
                    844: [123] deval(sin(1)^2+cos(1)^2);
                    845: 1
1.1       noro      846: @end example
                    847:
                    848: @table @t
1.2       noro      849: \JP @item $B;2>H(B
                    850: \EG @item References
1.12      noro      851: @fref{ctrl}, @fref{setbprec setprec}.
1.1       noro      852: @end table
                    853:
1.2       noro      854: \JP @node pari,,, $B?t$N1i;;(B
                    855: \EG @node pari,,, Numbers
1.1       noro      856: @subsection @code{pari}
                    857: @findex pari
                    858: @cindex PARI
                    859:
                    860: @table @t
                    861: @item pari(@var{func},@var{arg},@var{prec})
1.2       noro      862: \JP :: @b{PARI} $B$NH!?t(B @var{func} $B$r8F$S=P$9(B.
                    863: \EG :: Call @b{PARI} function @var{func}.
1.1       noro      864: @end table
                    865:
                    866: @table @var
                    867: @item return
1.2       noro      868: \JP @var{func} $BKh$K0[$J$k(B.
                    869: \EG Depends on @var{func}.
1.1       noro      870: @item func
1.2       noro      871: \JP @b{PARI} $B$NH!?tL>(B
                    872: \EG Function name of @b{PARI}.
1.1       noro      873: @item arg
1.2       noro      874: \JP @var{func} $B$N0z?t(B
                    875: \EG Arguments of @var{func}.
1.1       noro      876: @item prec
1.2       noro      877: \JP $B@0?t(B
                    878: \EG integer
1.1       noro      879: @end table
                    880:
                    881: @itemize @bullet
1.2       noro      882: \BJP
1.1       noro      883: @item
                    884: @b{PARI} $B$NH!?t$r8F$S=P$9(B.
                    885:
                    886: @item
                    887: @b{PARI} @code{[Batut et al.]} $B$O(B Bordeaux $BBg3X$G3+H/$5$l%U(B
                    888: $B%j!<%=%U%H%&%'%"$H$7$F8x3+$5$l$F$$$k(B. @b{PARI} $B$O?t<0=hM}E*$J5!G=$rM-(B
                    889: $B$7$F$O$$$k$,(B, $B<g$J%?!<%2%C%H$O@0?tO@$K4XO"$7$??t(B (@b{bignum},
                    890: @b{bigfloat}) $B$N1i;;$G(B, $B;MB'1i;;$K8B$i$:(B@b{bigfloat} $B$K$h$k$5$^$6$^$J(B
                    891: $BH!?tCM$NI>2A$r9bB.$K9T$&$3$H$,$G$-$k(B. @b{PARI} $B$OB>$N%W%m%0%i%`$+$i(B
                    892: $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
                    893: @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      894: $BMxMQ$9$k$3$H$b$G$-$k(B.
1.1       noro      895: @item
                    896: $B:G8e$N0z?t(B @var{prec} $B$G7W;;@:EY$r;XDj$G$-$k(B.
                    897: @var{prec} $B$r>JN,$7$?>l9g(B @code{setprec()} $B$G;XDj$7$?@:EY$H$J$k(B.
                    898: @item
1.14    ! takayama  899: $B8=;~E@$G<B9T$G$-$k(B @b{PARI} $B$N<g$JH!?t$O<!$NDL$j$G$"$k(B. $B$$$:$l$b(B
1.1       noro      900: 1 $B0z?t$G(B @b{Asir} $B$,BP1~$G$-$k7?$N0z?t$r$H$kH!?t$G$"$k(B.
1.14    ! takayama  901: $B<B9T$G$-$kH!?t$NA4%j%9%H$O(B asir-contrib $B$N(B ox_pari $B%^%K%e%"%k$r;2>H(B.
1.1       noro      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: @item
                    918: The last argument (optional) @var{int} specifies the precision in digits
                    919: for bigfloat operation.
                    920: If the precision is not explicitly specified, operation will be performed
                    921: with the precision set by @code{setprec()}.
                    922: @item
1.14    ! takayama  923: Some of currently available functions of @b{PARI} system are as follows.
1.2       noro      924: Note these are only a part of functions in @b{PARI} system.
1.14    ! takayama  925: A complete list of functions which can be called from asir
        !           926: is in the ox_pari manual of the asir-contrib.
1.2       noro      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
1.11      noro     1065: @b{Asir} $B$GMQ$$$F$$$k$N$O(B @b{PARI} $B$N$[$s$N0lIt$N5!G=$G$"$k(B.
1.2       noro     1066: \E
                   1067: \BEG
                   1068: @item
                   1069: @b{Asir} currently uses only a very small subset of @b{PARI}.
                   1070: \E
1.1       noro     1071: @end itemize
                   1072:
                   1073: @example
1.2       noro     1074: \JP /* $B9TNs$N8GM-%Y%/%H%k$r5a$a$k(B. */
                   1075: \EG /* Eigen vectors of a numerical matrix */
1.1       noro     1076: [0] pari(eigen,newmat(2,2,[[1,1],[1,2]]));
                   1077: [ -1.61803398874989484819771921990 0.61803398874989484826 ]
                   1078: [ 1 1 ]
1.2       noro     1079: \JP /* 1 $BJQ?tB?9`<0$N:,$r5a$a$k(B. */
                   1080: \EG /* Roots of a polynomial */
1.1       noro     1081: [1] pari(roots,t^2-2);
                   1082: [ -1.41421356237309504876 1.41421356237309504876 ]
                   1083: @end example
                   1084:
                   1085: @table @t
1.2       noro     1086: \JP @item $B;2>H(B
                   1087: \EG @item References
1.12      noro     1088: @fref{setbprec setprec}.
1.1       noro     1089: @end table
                   1090:
1.11      noro     1091: \JP @node setbprec setprec,,, $B?t$N1i;;(B
                   1092: \EG @node setbprec setprec,,, Numbers
                   1093: @subsection @code{setbprec}, @code{setprec}
                   1094: @findex setbprec
1.1       noro     1095: @findex setprec
                   1096:
                   1097: @table @t
1.11      noro     1098: @item setbprec([@var{n}])
                   1099: @itemx setprec([@var{n}])
                   1100: \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.
                   1101: \EG :: @b{setbprec}, @b{setprec} set the precision for @b{bigfloat} operations to @var{n} bits, @var{n} digits respectively.
1.1       noro     1102: @end table
                   1103:
                   1104: @table @var
                   1105: @item return
1.2       noro     1106: \JP $B@0?t(B
                   1107: \EG integer
1.1       noro     1108: @item n
1.2       noro     1109: \JP $B@0?t(B
                   1110: \EG integer
1.1       noro     1111: @end table
                   1112:
                   1113: @itemize @bullet
1.2       noro     1114: \BJP
1.1       noro     1115: @item
                   1116: $B0z?t$,$"$k>l9g(B, @b{bigfloat} $B$N7e?t$r(B @var{n} $B7e$K@_Dj$9$k(B.
                   1117: $B0z?t$N$"$k$J$7$K$+$+$o$i$:(B, $B0JA0$K@_Dj$5$l$F$$$?CM$rJV$9(B.
                   1118: @item
1.11      noro     1119: @b{bigfloat} $B$N7W;;$O(B @b{MPFR} $B%i%$%V%i%j$K$h$C$F9T$o$l$k(B.
1.1       noro     1120: @item
                   1121: @b{bigfloat} $B$G$N7W;;$KBP$7M-8z$G$"$k(B.
                   1122: @b{bigfloat} $B$N(B flag $B$r(B on $B$K$9$kJ}K!$O(B, @code{ctrl} $B$r;2>H(B.
                   1123: @item
                   1124: $B@_Dj$G$-$k7e?t$K>e8B$O$J$$$,(B, $B;XDj$7$?7e?t$K@_Dj$5$l$k$H$O(B
                   1125: $B8B$i$J$$(B. $BBg$-$a$NCM$r@_Dj$9$k$N$,0BA4$G$"$k(B.
1.2       noro     1126: \E
                   1127: \BEG
                   1128: @item
1.11      noro     1129: When an argument @var{n} is given, these functions
                   1130: set the precision for @b{bigfloat} operations to @var{n} bits or @var{n} digits.
                   1131: The return value is always the previous precision regardless of
1.2       noro     1132: the existence of an argument.
                   1133:
                   1134: @item
1.11      noro     1135: @b{Bigfloat} operations are done by @b{MPFR} library.
1.2       noro     1136: @item
                   1137: This is effective for computations in @b{bigfloat}.
                   1138: Refer to @code{ctrl()} for turning on the `@b{bigfloat} flag.'
                   1139: @item
                   1140: There is no upper limit for precision digits.
                   1141: It sets the precision to some digits around the specified precision.
                   1142: Therefore, it is safe to specify a larger value.
                   1143: \E
1.1       noro     1144: @end itemize
                   1145:
                   1146: @example
                   1147: [1] setprec();
1.11      noro     1148: 15
                   1149: [2] setprec(100);
                   1150: 15
                   1151: [3] setprec(100);
                   1152: 99
                   1153: [4] setbprec();
                   1154: 332
                   1155: @end example
                   1156:
                   1157: @table @t
                   1158: \JP @item $B;2>H(B
                   1159: @fref{ctrl}, @fref{eval deval}.
                   1160: @end table
                   1161:
                   1162: \JP @node setround,,, $B?t$N1i;;(B
                   1163: \EG @node setround,,, Numbers
                   1164: @subsection @code{setround}
                   1165: @findex setround
                   1166:
                   1167: @table @t
                   1168: @item setround([@var{mode}])
                   1169: \JP :: @b{bigfloat} $B$N4]$a%b!<%I$r(B @var{mode} $B$K@_Dj$9$k(B.
                   1170: \EG :: Sets the rounding mode @var{mode}.
                   1171: @end table
                   1172:
                   1173: @table @var
                   1174: @item return
                   1175: \JP $B@0?t(B
                   1176: \EG integer
                   1177: @item mode
                   1178: \JP $B@0?t(B
                   1179: \EG integer
                   1180: @end table
                   1181:
                   1182: @itemize @bullet
                   1183: \BJP
                   1184: @item
                   1185: $B0z?t$,$"$k>l9g(B, @b{bigfloat} $B$N4]$a%b!<%I$r(B @var{mode} $B$K@_Dj$9$k(B.
                   1186: $B0z?t$N$"$k$J$7$K$+$+$o$i$:(B, $B0JA0$K@_Dj$5$l$F$$$?CM$rJV$9(B.
                   1187: $B4]$a%b!<%I$N0UL#$O<!$N$H$*$j(B.
                   1188: @table @code
                   1189: @item 0
                   1190: Round to nearest
                   1191: @item 1
                   1192: Round toward 0
                   1193: @item 2
                   1194: Round toward +infinity
                   1195: @item 3
                   1196: Round toward -infinity
                   1197: @end table
                   1198: @item
                   1199: @b{bigfloat} $B$G$N7W;;$KBP$7M-8z$G$"$k(B.
                   1200: @b{bigfloat} $B$N(B flag $B$r(B on $B$K$9$kJ}K!$O(B, @code{ctrl} $B$r;2>H(B.
                   1201: \E
                   1202: \BEG
                   1203: @item
                   1204: When an argument @var{mode} is given, these functions
                   1205: set the rounding mode for @b{bigfloat} operations to @var{mode}.
                   1206: The return value is always the previous rounding mode regardless of
                   1207: the existence of an argument.
                   1208: The meanings of rounding modes are as follows
                   1209: @table @code
                   1210: @item 0
                   1211: Round to nearest
                   1212: @item 1
                   1213: Round toward 0
                   1214: @item 2
                   1215: Round toward +infinity
                   1216: @item 3
                   1217: Round toward -infinity
                   1218: @end table
                   1219:
                   1220: @item
                   1221: This is effective for computations in @b{bigfloat}.
                   1222: Refer to @code{ctrl()} for turning on the `@b{bigfloat} flag.'
                   1223: \E
                   1224: @end itemize
                   1225:
                   1226: @example
                   1227: [1] setprec();
                   1228: 15
1.1       noro     1229: [2] setprec(100);
1.11      noro     1230: 15
1.1       noro     1231: [3] setprec(100);
1.11      noro     1232: 99
                   1233: [4] setbprec();
                   1234: 332
1.1       noro     1235: @end example
                   1236:
                   1237: @table @t
1.2       noro     1238: \JP @item $B;2>H(B
1.11      noro     1239: @fref{ctrl}, @fref{eval deval}.
1.1       noro     1240: @end table
                   1241:
1.11      noro     1242:
1.2       noro     1243: \JP @node setmod,,, $B?t$N1i;;(B
                   1244: \EG @node setmod,,, Numbers
1.1       noro     1245: @subsection @code{setmod}
                   1246: @findex setmod
                   1247:
                   1248: @table @t
                   1249: @item setmod([@var{p}])
1.2       noro     1250: \JP :: $BM-8BBN$r(B GF(@var{p}) $B$K@_Dj$9$k(B.
                   1251: \EG :: Sets the ground field to GF(@var{p}).
1.1       noro     1252: @end table
                   1253:
                   1254: @table @var
                   1255: @item return
1.2       noro     1256: \JP $B@0?t(B
                   1257: \EG integer
1.1       noro     1258: @item n
1.2       noro     1259: \JP 2^27 $BL$K~$NAG?t(B
                   1260: \EG prime less than 2^27
1.1       noro     1261: @end table
                   1262:
                   1263: @itemize @bullet
1.2       noro     1264: \BJP
1.1       noro     1265: @item
                   1266: $BM-8BBN$r(B GF(@var{p}) $B$K@_Dj$9$k(B. $B@_DjCM$rJV$9(B.
                   1267: @item
                   1268: $BM-8BBN$N85$N7?$r;}$D?t$O(B, $B$=$l<+?H$O$I$NM-8BBN$KB0$9$k$+$N>pJs$r;}$?$:(B,
                   1269: $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     1270: @item
                   1271: $B0L?t$NBg$-$JM-8BBN$K4X$7$F$O(B @pxref{$BM-8BBN$K4X$9$k1i;;(B}.
                   1272: \E
                   1273: \BEG
                   1274: @item
                   1275: Sets the ground field to GF(@var{p}) and returns the value @var{p}.
                   1276: @item
                   1277: A member of a finite field does not have any information
                   1278: about the field and the arithmetic operations over GF(@var{p}) are applied
                   1279: with @var{p} set at the time.
                   1280: @item
                   1281: As for large finite fields, @pxref{Finite fields}.
                   1282: \E
1.1       noro     1283: @end itemize
                   1284:
                   1285: @example
                   1286: [0] A=dp_mod(dp_ptod(2*x,[x]),3,[]);
                   1287: (2)*<<1>>
                   1288: [1] A+A;
                   1289: addmi : invalid modulus
                   1290: return to toplevel
                   1291: [1] setmod(3);
                   1292: 3
                   1293: [2] A+A;
                   1294: (1)*<<1>>
                   1295: @end example
                   1296:
                   1297: @table @t
1.2       noro     1298: \JP @item $B;2>H(B
                   1299: \EG @item References
                   1300: \JP @fref{dp_mod dp_rat}, @fref{$B?t$N7?(B}.
                   1301: \EG @fref{dp_mod dp_rat}, @fref{Types of numbers}.
1.1       noro     1302: @end table
                   1303:
1.3       noro     1304: \JP @node ntoint32 int32ton,,, $B?t$N1i;;(B
                   1305: \EG @node ntoint32 int32ton,,, Numbers
                   1306: @subsection @code{ntoint32}, @code{int32ton}
                   1307: @findex ntoint32
                   1308: @findex int32ton
                   1309:
                   1310: @table @t
                   1311: @item ntoint32(@var{n})
                   1312: @itemx int32ton(@var{int32})
                   1313: \JP :: $BHsIi@0?t$HId9f$J$7(B 32bit $B@0?t$N4V$N7?JQ49(B.
                   1314: \EG :: Type-conversion between a non-negative integer and an unsigned 32bit integer.
                   1315: @end table
                   1316:
                   1317: @table @var
                   1318: @item return
                   1319: \JP $BId9f$J$7(B 32bit $B@0?t$^$?$OHsIi@0?t(B
                   1320: \EG unsigned 32bit integer or non-negative integer
                   1321: @item n
                   1322: \JP 2^32 $BL$K~$NHsIi@0?t(B
                   1323: \EG non-negative interger less than 2^32
                   1324: @item int32
                   1325: \JP $BId9f$J$7(B 32bit $B@0?t(B
                   1326: \EG unsigned 32bit integer
                   1327: @end table
                   1328:
                   1329: @itemize @bullet
                   1330: \BJP
                   1331: @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,
                   1332: $B$^$?$O$=$N5UJQ49$r9T$&(B.
                   1333: @item 32bit $B@0?t$O(B @b{OpenXM} $B$N4pK\9=@.MWAG$G$"$j(B, $B@0?t$r$=$N7?$GAw?.(B
                   1334: $B$9$kI,MW$,$"$k>l9g$KMQ$$$k(B.
                   1335: \E
                   1336: \BEG
                   1337: @item These functions do conversions between non-negative
                   1338: integers (the type id 1) and unsigned 32bit integers (the type id 10).
                   1339: @item An unsigned 32bit integer is a fundamental construct of @b{OpenXM}
                   1340: and one often has to send an integer to a server as an unsigned 32bit
                   1341: integer. These functions are used in such a case.
                   1342: \E
                   1343: @end itemize
                   1344:
                   1345: @table @t
                   1346: \JP @item $B;2>H(B
                   1347: \EG @item References
                   1348: \JP @fref{$BJ,;67W;;(B}, @fref{$B?t$N7?(B}.
                   1349: \EG @fref{Distributed computation}, @fref{Types of numbers}.
                   1350: @end table
1.13      noro     1351:
                   1352: \JP @node inttorat,,, $B?t$N1i;;(B
                   1353: \EG @node inttorat,,, Numbers
                   1354: @subsection @code{inttorat}
                   1355: @findex inttorat
                   1356:
                   1357: @table @t
                   1358: @item inttorat(@var{a},@var{m},@var{b})
                   1359: \JP :: $B@0?t(B-$BM-M}?tJQ49$r9T$&(B.
                   1360: \EG :: Perform the rational reconstruction.
                   1361: @end table
                   1362:
                   1363: @table @var
                   1364: @item return
                   1365: \JP $B%j%9%H$^$?$O(B 0
                   1366: \EG list or 0
                   1367: @item a
                   1368: @itemx m
                   1369: @itemx b
                   1370: \JP $B@0?t(B
                   1371: \EG integer
                   1372: @end table
                   1373:
                   1374: @itemize @bullet
                   1375: \BJP
                   1376: @item
                   1377: $B@0?t(B @var{a} $B$KBP$7(B, @var{xa=y} mod @var{m} $B$rK~$?$9@5@0?t(B @var{x}, $B@0?t(B @var{y}
                   1378: (@var{x}, @var{|y|} < @var{b}, @var{GCD(x,y)=1}) $B$r5a$a$k(B.
                   1379: @item
                   1380: $B$3$N$h$&$J(B @var{x}, @var{y} $B$,B8:_$9$k$J$i(B @var{[y,x]} $B$rJV$7(B, $BB8:_$7$J$$>l9g$K$O(B 0 $B$rJV$9(B.
                   1381: @item
                   1382: @var{b} $B$r(B @var{floor(sqrt(m/2))} $B$H<h$l$P(B, @var{x}, @var{y} $B$OB8:_$9$l$P0l0U$G$"$k(B.
                   1383: @var{floor(sqrt(m/2))} $B$O(B @code{isqrt(floor(m/2))} $B$G7W;;$G$-$k(B.
                   1384: @end itemize
                   1385: \E
                   1386: \BEG
                   1387: @item
                   1388: For an integer @var{a}, find a positive integer @var{x} and an intger @var{y} satisfying
                   1389: @var{xa=y} mod @var{m}, @var{x}, @var{|y|} < @var{b} and @var{GCD(x,y)=1}.
                   1390: @item
                   1391: If such @var{x}, @var{y} exist then a list @var{[y,x]} is returned. Otherwise 0 is returned.
                   1392: @item
                   1393: If @var{b} is set to @var{floor(sqrt(M/2))}, then @var{x} and @var{y} are unique if they
                   1394: exist. @var{floor(sqrt(M/2))} can be computed by @code{floor} and @code{isqrt}.
                   1395: @end itemize
                   1396: \E
                   1397:
                   1398: @example
                   1399: [2121] M=lprime(0)*lprime(1);
                   1400: 9996359931312779
                   1401: [2122] B=isqrt(floor(M/2));
                   1402: 70697807
                   1403: [2123] A=234234829304;
                   1404: 234234829304
                   1405: [2124] inttorat(A,M,B);
                   1406: [-20335178,86975031]
                   1407: @end example
                   1408:
                   1409: @table @t
                   1410: \JP @item $B;2>H(B
                   1411: \EG @item References
                   1412: @fref{floor}, @fref{isqrt}.
                   1413: @end table

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