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

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

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