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

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

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