[BACK]Return to gmp.info-2 CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / gmp

Annotation of OpenXM_contrib/gmp/gmp.info-2, Revision 1.1.1.2

1.1.1.2 ! maekawa     1: This is gmp.info, produced by makeinfo version 4.0 from gmp.texi.
1.1       maekawa     2:
1.1.1.2 ! maekawa     3: INFO-DIR-SECTION GNU libraries
1.1       maekawa     4: START-INFO-DIR-ENTRY
1.1.1.2 ! maekawa     5: * gmp: (gmp).                   GNU Multiple Precision Arithmetic Library.
1.1       maekawa     6: END-INFO-DIR-ENTRY
                      7:
                      8:    This file documents GNU MP, a library for arbitrary-precision
                      9: arithmetic.
                     10:
1.1.1.2 ! maekawa    11:    Copyright (C) 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
        !            12: Free Software Foundation, Inc.
1.1       maekawa    13:
                     14:    Permission is granted to make and distribute verbatim copies of this
                     15: manual provided the copyright notice and this permission notice are
                     16: preserved on all copies.
                     17:
                     18:    Permission is granted to copy and distribute modified versions of
                     19: this manual under the conditions for verbatim copying, provided that
                     20: the entire resulting derived work is distributed under the terms of a
                     21: permission notice identical to this one.
                     22:
                     23:    Permission is granted to copy and distribute translations of this
                     24: manual into another language, under the above conditions for modified
                     25: versions, except that this permission notice may be stated in a
                     26: translation approved by the Foundation.
                     27:
                     28: 
1.1.1.2 ! maekawa    29: File: gmp.info,  Node: Integer Exponentiation,  Next: Integer Roots,  Prev: Integer Division,  Up: Integer Functions
        !            30:
        !            31: Exponentiation Functions
        !            32: ========================
        !            33:
        !            34:  - Function: void mpz_powm (mpz_t ROP, mpz_t BASE, mpz_t EXP, mpz_t MOD)
        !            35:  - Function: void mpz_powm_ui (mpz_t ROP, mpz_t BASE, unsigned long int
        !            36:           EXP, mpz_t MOD)
        !            37:      Set ROP to (BASE raised to EXP) `mod' MOD.  If EXP is negative,
        !            38:      the result is undefined.
        !            39:
        !            40:
        !            41:  - Function: void mpz_pow_ui (mpz_t ROP, mpz_t BASE, unsigned long int
        !            42:           EXP)
        !            43:  - Function: void mpz_ui_pow_ui (mpz_t ROP, unsigned long int BASE,
        !            44:           unsigned long int EXP)
        !            45:      Set ROP to BASE raised to EXP.  The case of 0^0 yields 1.
        !            46:
        !            47: 
        !            48: File: gmp.info,  Node: Integer Roots,  Next: Number Theoretic Functions,  Prev: Integer Exponentiation,  Up: Integer Functions
        !            49:
        !            50: Root Extraction Functions
        !            51: =========================
        !            52:
        !            53:  - Function: int mpz_root (mpz_t ROP, mpz_t OP, unsigned long int N)
        !            54:      Set ROP to the truncated integer part of the Nth root of OP.
        !            55:      Return non-zero if the computation was exact, i.e., if OP is ROP
        !            56:      to the Nth power.
        !            57:
        !            58:  - Function: void mpz_sqrt (mpz_t ROP, mpz_t OP)
        !            59:      Set ROP to the truncated integer part of the square root of OP.
        !            60:
        !            61:  - Function: void mpz_sqrtrem (mpz_t ROP1, mpz_t ROP2, mpz_t OP)
        !            62:      Set ROP1 to the truncated integer part of the square root of OP,
        !            63:      like `mpz_sqrt'.  Set ROP2 to OP-ROP1*ROP1, (i.e., zero if OP is a
        !            64:      perfect square).
        !            65:
        !            66:      If ROP1 and ROP2 are the same variable, the results are undefined.
        !            67:
        !            68:  - Function: int mpz_perfect_power_p (mpz_t OP)
        !            69:      Return non-zero if OP is a perfect power, i.e., if there exist
        !            70:      integers A and B, with B > 1, such that OP equals a raised to b.
        !            71:      Return zero otherwise.
        !            72:
        !            73:  - Function: int mpz_perfect_square_p (mpz_t OP)
        !            74:      Return non-zero if OP is a perfect square, i.e., if the square
        !            75:      root of OP is an integer.  Return zero otherwise.
        !            76:
        !            77: 
        !            78: File: gmp.info,  Node: Number Theoretic Functions,  Next: Integer Comparisons,  Prev: Integer Roots,  Up: Integer Functions
        !            79:
        !            80: Number Theoretic Functions
        !            81: ==========================
        !            82:
        !            83:  - Function: int mpz_probab_prime_p (mpz_t N, int REPS)
        !            84:      If this function returns 0, N is definitely not prime.  If it
        !            85:      returns 1, then N is `probably' prime.  If it returns 2, then N is
        !            86:      surely prime.  Reasonable values of reps vary from 5 to 10; a
        !            87:      higher value lowers the probability for a non-prime to pass as a
        !            88:      `probable' prime.
        !            89:
        !            90:      The function uses Miller-Rabin's probabilistic test.
        !            91:
        !            92:  - Function: int mpz_nextprime (mpz_t ROP, mpz_t OP)
        !            93:      Set ROP to the next prime greater than OP.
        !            94:
        !            95:      This function uses a probabilistic algorithm to identify primes,
        !            96:      but for for practical purposes it's adequate, since the chance of
        !            97:      a composite passing will be extremely small.
        !            98:
        !            99:  - Function: void mpz_gcd (mpz_t ROP, mpz_t OP1, mpz_t OP2)
        !           100:      Set ROP to the greatest common divisor of OP1 and OP2.  The result
        !           101:      is always positive even if either of or both input operands are
        !           102:      negative.
        !           103:
        !           104:  - Function: unsigned long int mpz_gcd_ui (mpz_t ROP, mpz_t OP1,
        !           105:           unsigned long int OP2)
        !           106:      Compute the greatest common divisor of OP1 and OP2.  If ROP is not
        !           107:      `NULL', store the result there.
        !           108:
        !           109:      If the result is small enough to fit in an `unsigned long int', it
        !           110:      is returned.  If the result does not fit, 0 is returned, and the
        !           111:      result is equal to the argument OP1.  Note that the result will
        !           112:      always fit if OP2 is non-zero.
        !           113:
        !           114:  - Function: void mpz_gcdext (mpz_t G, mpz_t S, mpz_t T, mpz_t A, mpz_t
        !           115:           B)
        !           116:      Compute G, S, and T, such that AS + BT = G = `gcd'(A, B).  If T is
        !           117:      `NULL', that argument is not computed.
        !           118:
        !           119:  - Function: void mpz_lcm (mpz_t ROP, mpz_t OP1, mpz_t OP2)
        !           120:      Set ROP to the least common multiple of OP1 and OP2.
        !           121:
        !           122:  - Function: int mpz_invert (mpz_t ROP, mpz_t OP1, mpz_t OP2)
        !           123:      Compute the inverse of OP1 modulo OP2 and put the result in ROP.
        !           124:      Return non-zero if an inverse exists, zero otherwise.  When the
        !           125:      function returns zero, ROP is undefined.
        !           126:
        !           127:  - Function: int mpz_jacobi (mpz_t OP1, mpz_t OP2)
        !           128:  - Function: int mpz_legendre (mpz_t OP1, mpz_t OP2)
        !           129:      Compute the Jacobi and Legendre symbols, respectively.  OP2 should
        !           130:      be odd and must be positive.
        !           131:
        !           132:  - Function: int mpz_si_kronecker (long A, mpz_t B);
        !           133:  - Function: int mpz_ui_kronecker (unsigned long A, mpz_t B);
        !           134:  - Function: int mpz_kronecker_si (mpz_t A, long B);
        !           135:  - Function: int mpz_kronecker_ui (mpz_t A, unsigned long B);
        !           136:      Calculate the value of the Kronecker/Jacobi symbol (A/B), with the
        !           137:      Kronecker extension (a/2)=(2/a) when a odd, or (a/2)=0 when a even.
        !           138:      All values of A and B give a well-defined result.  See Henri
        !           139:      Cohen, section 1.4.2, for more information (*note References::).
        !           140:      See also the example program `demos/qcn.c' which uses
        !           141:      `mpz_kronecker_ui'.
        !           142:
        !           143:  - Function: unsigned long int mpz_remove (mpz_t ROP, mpz_t OP, mpz_t F)
        !           144:      Remove all occurrences of the factor F from OP and store the
        !           145:      result in ROP.  Return the multiplicity of F in OP.
        !           146:
        !           147:  - Function: void mpz_fac_ui (mpz_t ROP, unsigned long int OP)
        !           148:      Set ROP to OP!, the factorial of OP.
        !           149:
        !           150:  - Function: void mpz_bin_ui (mpz_t ROP, mpz_t N, unsigned long int K)
        !           151:  - Function: void mpz_bin_uiui (mpz_t ROP, unsigned long int N,
        !           152:           unsigned long int K)
        !           153:      Compute the binomial coefficient N over K and store the result in
        !           154:      ROP.  Negative values of N are supported by `mpz_bin_ui', using
        !           155:      the identity bin(-n,k) = (-1)^k * bin(n+k-1,k) (see Knuth volume 1
        !           156:      section 1.2.6 part G).
        !           157:
        !           158:  - Function: void mpz_fib_ui (mpz_t ROP, unsigned long int N)
        !           159:      Compute the Nth Fibonacci number and store the result in ROP.
        !           160:
        !           161: 
        !           162: File: gmp.info,  Node: Integer Comparisons,  Next: Integer Logic and Bit Fiddling,  Prev: Number Theoretic Functions,  Up: Integer Functions
        !           163:
        !           164: Comparison Functions
        !           165: ====================
        !           166:
        !           167:  - Function: int mpz_cmp (mpz_t OP1, mpz_t OP2)
        !           168:      Compare OP1 and OP2.  Return a positive value if OP1 > OP2, zero
        !           169:      if OP1 = OP2, and a negative value if OP1 < OP2.
        !           170:
        !           171:  - Macro: int mpz_cmp_ui (mpz_t OP1, unsigned long int OP2)
        !           172:  - Macro: int mpz_cmp_si (mpz_t OP1, signed long int OP2)
        !           173:      Compare OP1 and OP2.  Return a positive value if OP1 > OP2, zero
        !           174:      if OP1 = OP2, and a negative value if OP1 < OP2.
        !           175:
        !           176:      These functions are actually implemented as macros.  They evaluate
        !           177:      their arguments multiple times.
        !           178:
        !           179:  - Function: int mpz_cmpabs (mpz_t OP1, mpz_t OP2)
        !           180:  - Function: int mpz_cmpabs_ui (mpz_t OP1, unsigned long int OP2)
        !           181:      Compare the absolute values of OP1 and OP2.  Return a positive
        !           182:      value if OP1 > OP2, zero if OP1 = OP2, and a negative value if OP1
        !           183:      < OP2.
        !           184:
        !           185:  - Macro: int mpz_sgn (mpz_t OP)
        !           186:      Return +1 if OP > 0, 0 if OP = 0, and -1 if OP < 0.
        !           187:
        !           188:      This function is actually implemented as a macro.  It evaluates its
        !           189:      arguments multiple times.
        !           190:
        !           191: 
        !           192: File: gmp.info,  Node: Integer Logic and Bit Fiddling,  Next: I/O of Integers,  Prev: Integer Comparisons,  Up: Integer Functions
        !           193:
        !           194: Logical and Bit Manipulation Functions
        !           195: ======================================
        !           196:
        !           197:    These functions behave as if two's complement arithmetic were used
        !           198: (although sign-magnitude is used by the actual implementation).
        !           199:
        !           200:  - Function: void mpz_and (mpz_t ROP, mpz_t OP1, mpz_t OP2)
        !           201:      Set ROP to OP1 logical-and OP2.
        !           202:
        !           203:  - Function: void mpz_ior (mpz_t ROP, mpz_t OP1, mpz_t OP2)
        !           204:      Set ROP to OP1 inclusive-or OP2.
        !           205:
        !           206:  - Function: void mpz_xor (mpz_t ROP, mpz_t OP1, mpz_t OP2)
        !           207:      Set ROP to OP1 exclusive-or OP2.
        !           208:
        !           209:  - Function: void mpz_com (mpz_t ROP, mpz_t OP)
        !           210:      Set ROP to the one's complement of OP.
        !           211:
        !           212:  - Function: unsigned long int mpz_popcount (mpz_t OP)
        !           213:      For non-negative numbers, return the population count of OP.  For
        !           214:      negative numbers, return the largest possible value (MAX_ULONG).
        !           215:
        !           216:  - Function: unsigned long int mpz_hamdist (mpz_t OP1, mpz_t OP2)
        !           217:      If OP1 and OP2 are both non-negative, return the hamming distance
        !           218:      between the two operands.  Otherwise, return the largest possible
        !           219:      value (MAX_ULONG).
        !           220:
        !           221:      It is possible to extend this function to return a useful value
        !           222:      when the operands are both negative, but the current
        !           223:      implementation returns MAX_ULONG in this case.  *Do not depend on
        !           224:      this behavior, since it will change in a future release.*
        !           225:
        !           226:  - Function: unsigned long int mpz_scan0 (mpz_t OP, unsigned long int
        !           227:           STARTING_BIT)
        !           228:      Scan OP, starting with bit STARTING_BIT, towards more significant
        !           229:      bits, until the first clear bit is found.  Return the index of the
        !           230:      found bit.
        !           231:
        !           232:  - Function: unsigned long int mpz_scan1 (mpz_t OP, unsigned long int
        !           233:           STARTING_BIT)
        !           234:      Scan OP, starting with bit STARTING_BIT, towards more significant
        !           235:      bits, until the first set bit is found.  Return the index of the
        !           236:      found bit.
        !           237:
        !           238:  - Function: void mpz_setbit (mpz_t ROP, unsigned long int BIT_INDEX)
        !           239:      Set bit BIT_INDEX in ROP.
        !           240:
        !           241:  - Function: void mpz_clrbit (mpz_t ROP, unsigned long int BIT_INDEX)
        !           242:      Clear bit BIT_INDEX in ROP.
        !           243:
        !           244:  - Function: int mpz_tstbit (mpz_t OP, unsigned long int BIT_INDEX)
        !           245:      Check bit BIT_INDEX in OP and return 0 or 1 accordingly.
        !           246:
        !           247: 
        !           248: File: gmp.info,  Node: I/O of Integers,  Next: Integer Random Numbers,  Prev: Integer Logic and Bit Fiddling,  Up: Integer Functions
        !           249:
        !           250: Input and Output Functions
        !           251: ==========================
        !           252:
        !           253:    Functions that perform input from a stdio stream, and functions that
        !           254: output to a stdio stream.  Passing a `NULL' pointer for a STREAM
        !           255: argument to any of these functions will make them read from `stdin' and
        !           256: write to `stdout', respectively.
        !           257:
        !           258:    When using any of these functions, it is a good idea to include
        !           259: `stdio.h' before `gmp.h', since that will allow `gmp.h' to define
        !           260: prototypes for these functions.
        !           261:
        !           262:  - Function: size_t mpz_out_str (FILE *STREAM, int BASE, mpz_t OP)
        !           263:      Output OP on stdio stream STREAM, as a string of digits in base
        !           264:      BASE.  The base may vary from 2 to 36.
        !           265:
        !           266:      Return the number of bytes written, or if an error occurred,
        !           267:      return 0.
        !           268:
        !           269:  - Function: size_t mpz_inp_str (mpz_t ROP, FILE *STREAM, int BASE)
        !           270:      Input a possibly white-space preceded string in base BASE from
        !           271:      stdio stream STREAM, and put the read integer in ROP.  The base
        !           272:      may vary from 2 to 36.  If BASE is 0, the actual base is
        !           273:      determined from the leading characters: if the first two
        !           274:      characters are `0x' or `0X', hexadecimal is assumed, otherwise if
        !           275:      the first character is `0', octal is assumed, otherwise decimal is
        !           276:      assumed.
        !           277:
        !           278:      Return the number of bytes read, or if an error occurred, return 0.
        !           279:
        !           280:  - Function: size_t mpz_out_raw (FILE *STREAM, mpz_t OP)
        !           281:      Output OP on stdio stream STREAM, in raw binary format.  The
        !           282:      integer is written in a portable format, with 4 bytes of size
        !           283:      information, and that many bytes of limbs.  Both the size and the
        !           284:      limbs are written in decreasing significance order (i.e., in
        !           285:      big-endian).
        !           286:
        !           287:      The output can be read with `mpz_inp_raw'.
        !           288:
        !           289:      Return the number of bytes written, or if an error occurred,
        !           290:      return 0.
        !           291:
        !           292:      The output of this can not be read by `mpz_inp_raw' from GMP 1,
        !           293:      because of changes necessary for compatibility between 32-bit and
        !           294:      64-bit machines.
        !           295:
        !           296:  - Function: size_t mpz_inp_raw (mpz_t ROP, FILE *STREAM)
        !           297:      Input from stdio stream STREAM in the format written by
        !           298:      `mpz_out_raw', and put the result in ROP.  Return the number of
        !           299:      bytes read, or if an error occurred, return 0.
        !           300:
        !           301:      This routine can read the output from `mpz_out_raw' also from GMP
        !           302:      1, in spite of changes necessary for compatibility between 32-bit
        !           303:      and 64-bit machines.
        !           304:
        !           305: 
        !           306: File: gmp.info,  Node: Integer Random Numbers,  Next: Miscellaneous Integer Functions,  Prev: I/O of Integers,  Up: Integer Functions
        !           307:
        !           308: Random Number Functions
        !           309: =======================
        !           310:
        !           311:    The random number functions of GMP come in two groups; older function
        !           312: that rely on a global state, and newer functions that accept a state
        !           313: parameter that is read and modified.  Please see the *Note Random
        !           314: Number Functions:: for more information on how to use and not to use
        !           315: random number functions.
        !           316:
        !           317:  - Function: void mpz_urandomb (mpz_t ROP, gmp_randstate_t STATE,
        !           318:      unsigned long int N) Generate a uniformly distributed random
        !           319:      integer in the range 0 to 2^N - 1, inclusive.
        !           320:
        !           321:      The variable STATE must be initialized by calling one of the
        !           322:      `gmp_randinit' functions (*Note Random State Initialization::)
        !           323:      before invoking this function.
        !           324:
        !           325:  - Function: void mpz_urandomm (mpz_t ROP, gmp_randstate_t STATE,
        !           326:      mpz_t N) Generate a uniform random integer in the range 0 to N -
        !           327:      1, inclusive.
        !           328:
        !           329:      The variable STATE must be initialized by calling one of the
        !           330:      `gmp_randinit' functions (*Note Random State Initialization::)
        !           331:      before invoking this function.
        !           332:
        !           333:  - Function: void mpz_rrandomb (mpz_t ROP, gmp_randstate_t STATE,
        !           334:           unsigned long int N)
        !           335:      Generate a random integer with long strings of zeros and ones in
        !           336:      the binary representation.  Useful for testing functions and
        !           337:      algorithms, since this kind of random numbers have proven to be
        !           338:      more likely to trigger corner-case bugs.  The random number will
        !           339:      be in the range 0 to 2^N - 1, inclusive.
        !           340:
        !           341:      The variable STATE must be initialized by calling one of the
        !           342:      `gmp_randinit' functions (*Note Random State Initialization::)
        !           343:      before invoking this function.
        !           344:
        !           345:  - Function: void mpz_random (mpz_t ROP, mp_size_t MAX_SIZE)
        !           346:      Generate a random integer of at most MAX_SIZE limbs.  The generated
        !           347:      random number doesn't satisfy any particular requirements of
        !           348:      randomness.  Negative random numbers are generated when MAX_SIZE
        !           349:      is negative.
        !           350:
        !           351:      This function is obsolete.  Use `mpz_urandomb' or `mpz_urandomm'
        !           352:      instead.
        !           353:
        !           354:  - Function: void mpz_random2 (mpz_t ROP, mp_size_t MAX_SIZE)
        !           355:      Generate a random integer of at most MAX_SIZE limbs, with long
        !           356:      strings of zeros and ones in the binary representation.  Useful
        !           357:      for testing functions and algorithms, since this kind of random
        !           358:      numbers have proven to be more likely to trigger corner-case bugs.
        !           359:      Negative random numbers are generated when MAX_SIZE is negative.
        !           360:
        !           361:      This function is obsolete.  Use `mpz_rrandomb' instead.
        !           362:
        !           363: 
        !           364: File: gmp.info,  Node: Miscellaneous Integer Functions,  Prev: Integer Random Numbers,  Up: Integer Functions
        !           365:
        !           366: Miscellaneous Functions
        !           367: =======================
        !           368:
        !           369:  - Function: int mpz_fits_ulong_p (mpz_t OP)
        !           370:  - Function: int mpz_fits_slong_p (mpz_t OP)
        !           371:  - Function: int mpz_fits_uint_p (mpz_t OP)
        !           372:  - Function: int mpz_fits_sint_p (mpz_t OP)
        !           373:  - Function: int mpz_fits_ushort_p (mpz_t OP)
        !           374:  - Function: int mpz_fits_sshort_p (mpz_t OP)
        !           375:      Return non-zero iff the value of OP fits in an `unsigned long int',
        !           376:      `signed long int', `unsigned int', `signed int', `unsigned short
        !           377:      int', or `signed short int', respectively.  Otherwise, return zero.
        !           378:
        !           379:  - Macro: int mpz_odd_p (mpz_t OP)
        !           380:  - Macro: int mpz_even_p (mpz_t OP)
        !           381:      Determine whether OP is odd or even, respectively.  Return
        !           382:      non-zero if yes, zero if no.  These macros evaluate their
        !           383:      arguments more than once.
        !           384:
        !           385:  - Function: size_t mpz_size (mpz_t OP)
        !           386:      Return the size of OP measured in number of limbs.  If OP is zero,
        !           387:      the returned value will be zero.
        !           388:
        !           389:  - Function: size_t mpz_sizeinbase (mpz_t OP, int BASE)
        !           390:      Return the size of OP measured in number of digits in base BASE.
        !           391:      The base may vary from 2 to 36.  The returned value will be exact
        !           392:      or 1 too big.  If BASE is a power of 2, the returned value will
        !           393:      always be exact.
        !           394:
        !           395:      This function is useful in order to allocate the right amount of
        !           396:      space before converting OP to a string.  The right amount of
        !           397:      allocation is normally two more than the value returned by
        !           398:      `mpz_sizeinbase' (one extra for a minus sign and one for the
        !           399:      terminating '\0').
        !           400:
        !           401: 
        !           402: File: gmp.info,  Node: Rational Number Functions,  Next: Floating-point Functions,  Prev: Integer Functions,  Up: Top
        !           403:
        !           404: Rational Number Functions
        !           405: *************************
        !           406:
        !           407:    This chapter describes the GMP functions for performing arithmetic
        !           408: on rational numbers.  These functions start with the prefix `mpq_'.
        !           409:
        !           410:    Rational numbers are stored in objects of type `mpq_t'.
        !           411:
        !           412:    All rational arithmetic functions assume operands have a canonical
        !           413: form, and canonicalize their result.  The canonical from means that the
        !           414: denominator and the numerator have no common factors, and that the
        !           415: denominator is positive.  Zero has the unique representation 0/1.
        !           416:
        !           417:    Pure assignment functions do not canonicalize the assigned variable.
        !           418: It is the responsibility of the user to canonicalize the assigned
        !           419: variable before any arithmetic operations are performed on that
        !           420: variable.  *Note that this is an incompatible change from version 1 of
        !           421: the library.*
        !           422:
        !           423:  - Function: void mpq_canonicalize (mpq_t OP)
        !           424:      Remove any factors that are common to the numerator and
        !           425:      denominator of OP, and make the denominator positive.
        !           426:
        !           427: * Menu:
        !           428:
        !           429: * Initializing Rationals::
        !           430: * Rational Arithmetic::
        !           431: * Comparing Rationals::
        !           432: * Applying Integer Functions::
        !           433: * I/O of Rationals::
        !           434: * Miscellaneous Rational Functions::
        !           435:
        !           436: 
        !           437: File: gmp.info,  Node: Initializing Rationals,  Next: Rational Arithmetic,  Prev: Rational Number Functions,  Up: Rational Number Functions
        !           438:
        !           439: Initialization and Assignment Functions
        !           440: =======================================
        !           441:
        !           442:  - Function: void mpq_init (mpq_t DEST_RATIONAL)
        !           443:      Initialize DEST_RATIONAL and set it to 0/1.  Each variable should
        !           444:      normally only be initialized once, or at least cleared out (using
        !           445:      the function `mpq_clear') between each initialization.
        !           446:
        !           447:  - Function: void mpq_clear (mpq_t RATIONAL_NUMBER)
        !           448:      Free the space occupied by RATIONAL_NUMBER.  Make sure to call this
        !           449:      function for all `mpq_t' variables when you are done with them.
        !           450:
        !           451:  - Function: void mpq_set (mpq_t ROP, mpq_t OP)
        !           452:  - Function: void mpq_set_z (mpq_t ROP, mpz_t OP)
        !           453:      Assign ROP from OP.
        !           454:
        !           455:  - Function: void mpq_set_ui (mpq_t ROP, unsigned long int OP1,
        !           456:           unsigned long int OP2)
        !           457:  - Function: void mpq_set_si (mpq_t ROP, signed long int OP1, unsigned
        !           458:           long int OP2)
        !           459:      Set the value of ROP to OP1/OP2.  Note that if OP1 and OP2 have
        !           460:      common factors, ROP has to be passed to `mpq_canonicalize' before
        !           461:      any operations are performed on ROP.
        !           462:
        !           463:  - Function: void mpq_swap (mpq_t ROP1, mpq_t ROP2)
        !           464:      Swap the values ROP1 and ROP2 efficiently.
        !           465:
        !           466: 
        !           467: File: gmp.info,  Node: Rational Arithmetic,  Next: Comparing Rationals,  Prev: Initializing Rationals,  Up: Rational Number Functions
        !           468:
        !           469: Arithmetic Functions
        !           470: ====================
        !           471:
        !           472:  - Function: void mpq_add (mpq_t SUM, mpq_t ADDEND1, mpq_t ADDEND2)
        !           473:      Set SUM to ADDEND1 + ADDEND2.
        !           474:
        !           475:  - Function: void mpq_sub (mpq_t DIFFERENCE, mpq_t MINUEND, mpq_t
        !           476:           SUBTRAHEND)
        !           477:      Set DIFFERENCE to MINUEND - SUBTRAHEND.
        !           478:
        !           479:  - Function: void mpq_mul (mpq_t PRODUCT, mpq_t MULTIPLIER, mpq_t
        !           480:           MULTIPLICAND)
        !           481:      Set PRODUCT to MULTIPLIER times MULTIPLICAND.
        !           482:
        !           483:  - Function: void mpq_div (mpq_t QUOTIENT, mpq_t DIVIDEND, mpq_t
        !           484:           DIVISOR)
        !           485:      Set QUOTIENT to DIVIDEND/DIVISOR.
        !           486:
        !           487:  - Function: void mpq_neg (mpq_t NEGATED_OPERAND, mpq_t OPERAND)
        !           488:      Set NEGATED_OPERAND to -OPERAND.
        !           489:
        !           490:  - Function: void mpq_inv (mpq_t INVERTED_NUMBER, mpq_t NUMBER)
        !           491:      Set INVERTED_NUMBER to 1/NUMBER.  If the new denominator is zero,
        !           492:      this routine will divide by zero.
        !           493:
        !           494: 
        !           495: File: gmp.info,  Node: Comparing Rationals,  Next: Applying Integer Functions,  Prev: Rational Arithmetic,  Up: Rational Number Functions
        !           496:
        !           497: Comparison Functions
        !           498: ====================
        !           499:
        !           500:  - Function: int mpq_cmp (mpq_t OP1, mpq_t OP2)
        !           501:      Compare OP1 and OP2.  Return a positive value if OP1 > OP2, zero
        !           502:      if OP1 = OP2, and a negative value if OP1 < OP2.
        !           503:
        !           504:      To determine if two rationals are equal, `mpq_equal' is faster than
        !           505:      `mpq_cmp'.
        !           506:
        !           507:  - Macro: int mpq_cmp_ui (mpq_t OP1, unsigned long int NUM2, unsigned
        !           508:           long int DEN2)
        !           509:      Compare OP1 and NUM2/DEN2.  Return a positive value if OP1 >
        !           510:      NUM2/DEN2, zero if OP1 = NUM2/DEN2, and a negative value if OP1 <
        !           511:      NUM2/DEN2.
        !           512:
        !           513:      This routine allows that NUM2 and DEN2 have common factors.
        !           514:
        !           515:      This function is actually implemented as a macro.  It evaluates its
        !           516:      arguments multiple times.
        !           517:
        !           518:  - Macro: int mpq_sgn (mpq_t OP)
        !           519:      Return +1 if OP > 0, 0 if OP = 0, and -1 if OP < 0.
        !           520:
        !           521:      This function is actually implemented as a macro.  It evaluates its
        !           522:      arguments multiple times.
        !           523:
        !           524:  - Function: int mpq_equal (mpq_t OP1, mpq_t OP2)
        !           525:      Return non-zero if OP1 and OP2 are equal, zero if they are
        !           526:      non-equal.  Although `mpq_cmp' can be used for the same purpose,
        !           527:      this function is much faster.
        !           528:
        !           529: 
        !           530: File: gmp.info,  Node: Applying Integer Functions,  Next: I/O of Rationals,  Prev: Comparing Rationals,  Up: Rational Number Functions
        !           531:
        !           532: Applying Integer Functions to Rationals
        !           533: =======================================
        !           534:
        !           535:    The set of `mpq' functions is quite small.  In particular, there are
        !           536: few functions for either input or output.  But there are two macros
        !           537: that allow us to apply any `mpz' function on the numerator or
        !           538: denominator of a rational number.  If these macros are used to assign
        !           539: to the rational number, `mpq_canonicalize' normally need to be called
        !           540: afterwards.
        !           541:
        !           542:  - Macro: mpz_t mpq_numref (mpq_t OP)
        !           543:  - Macro: mpz_t mpq_denref (mpq_t OP)
        !           544:      Return a reference to the numerator and denominator of OP,
        !           545:      respectively.  The `mpz' functions can be used on the result of
        !           546:      these macros.
        !           547:
        !           548: 
        !           549: File: gmp.info,  Node: I/O of Rationals,  Next: Miscellaneous Rational Functions,  Prev: Applying Integer Functions,  Up: Rational Number Functions
        !           550:
        !           551: Input and Output Functions
        !           552: ==========================
        !           553:
        !           554:    Functions that perform input from a stdio stream, and functions that
        !           555: output to a stdio stream.  Passing a `NULL' pointer for a STREAM
        !           556: argument to any of these functions will make them read from `stdin' and
        !           557: write to `stdout', respectively.
        !           558:
        !           559:    When using any of these functions, it is a good idea to include
        !           560: `stdio.h' before `gmp.h', since that will allow `gmp.h' to define
        !           561: prototypes for these functions.
        !           562:
        !           563:  - Function: size_t mpq_out_str (FILE *STREAM, int BASE, mpq_t OP)
        !           564:      Output OP on stdio stream STREAM, as a string of digits in base
        !           565:      BASE.  The base may vary from 2 to 36.  Output is in the form
        !           566:      `num/den' or if the denominator is 1 then just `num'.
        !           567:
        !           568:      Return the number of bytes written, or if an error occurred,
        !           569:      return 0.
        !           570:
        !           571: 
        !           572: File: gmp.info,  Node: Miscellaneous Rational Functions,  Prev: I/O of Rationals,  Up: Rational Number Functions
        !           573:
        !           574: Miscellaneous Functions
        !           575: =======================
        !           576:
        !           577:  - Function: double mpq_get_d (mpq_t OP)
        !           578:      Convert OP to a double.
        !           579:
        !           580:  - Function: double mpq_set_d (mpq_t ROP, double D)
        !           581:      Set ROP to the value of d, without rounding.
        !           582:
        !           583:    These functions assign between either the numerator or denominator
        !           584: of a rational, and an integer.  Instead of using these functions, it is
        !           585: preferable to use the more general mechanisms `mpq_numref' and
        !           586: `mpq_denref', together with `mpz_set'.
        !           587:
        !           588:  - Function: void mpq_set_num (mpq_t RATIONAL, mpz_t NUMERATOR)
        !           589:      Copy NUMERATOR to the numerator of RATIONAL.  When this risks to
        !           590:      make the numerator and denominator of RATIONAL have common
        !           591:      factors, you have to pass RATIONAL to `mpq_canonicalize' before
        !           592:      any operations are performed on RATIONAL.
        !           593:
        !           594:      This function is equivalent to `mpz_set (mpq_numref (RATIONAL),
        !           595:      NUMERATOR)'.
        !           596:
        !           597:  - Function: void mpq_set_den (mpq_t RATIONAL, mpz_t DENOMINATOR)
        !           598:      Copy DENOMINATOR to the denominator of RATIONAL.  When this risks
        !           599:      to make the numerator and denominator of RATIONAL have common
        !           600:      factors, or if the denominator might be negative, you have to pass
        !           601:      RATIONAL to `mpq_canonicalize' before any operations are performed
        !           602:      on RATIONAL.
        !           603:
        !           604:      *In version 1 of the library, negative denominators were handled by
        !           605:      copying the sign to the numerator.  That is no longer done.*
        !           606:
        !           607:      This function is equivalent to `mpz_set (mpq_denref (RATIONAL),
        !           608:      DENOMINATORS)'.
        !           609:
        !           610:  - Function: void mpq_get_num (mpz_t NUMERATOR, mpq_t RATIONAL)
        !           611:      Copy the numerator of RATIONAL to the integer NUMERATOR, to
        !           612:      prepare for integer operations on the numerator.
        !           613:
        !           614:      This function is equivalent to `mpz_set (NUMERATOR, mpq_numref
        !           615:      (RATIONAL))'.
        !           616:
        !           617:  - Function: void mpq_get_den (mpz_t DENOMINATOR, mpq_t RATIONAL)
        !           618:      Copy the denominator of RATIONAL to the integer DENOMINATOR, to
        !           619:      prepare for integer operations on the denominator.
        !           620:
        !           621:      This function is equivalent to `mpz_set (DENOMINATOR, mpq_denref
        !           622:      (RATIONAL))'.
        !           623:
        !           624: 
1.1       maekawa   625: File: gmp.info,  Node: Floating-point Functions,  Next: Low-level Functions,  Prev: Rational Number Functions,  Up: Top
                    626:
                    627: Floating-point Functions
                    628: ************************
                    629:
1.1.1.2 ! maekawa   630:    This chapter describes the GMP functions for performing floating
        !           631: point arithmetic.  These functions start with the prefix `mpf_'.
1.1       maekawa   632:
1.1.1.2 ! maekawa   633:    GMP floating point numbers are stored in objects of type `mpf_t'.
1.1       maekawa   634:
1.1.1.2 ! maekawa   635:    The GMP floating-point functions have an interface that is similar
        !           636: to the GMP integer functions.  The function prefix for floating-point
1.1       maekawa   637: operations is `mpf_'.
                    638:
                    639:    There is one significant characteristic of floating-point numbers
                    640: that has motivated a difference between this function class and other
1.1.1.2 ! maekawa   641: GMP function classes: the inherent inexactness of floating point
1.1       maekawa   642: arithmetic.  The user has to specify the precision of each variable.  A
                    643: computation that assigns a variable will take place with the precision
                    644: of the assigned variable; the precision of variables used as input is
                    645: ignored.
                    646:
                    647:    The precision of a calculation is defined as follows: Compute the
                    648: requested operation exactly (with "infinite precision"), and truncate
                    649: the result to the destination variable precision.  Even if the user has
1.1.1.2 ! maekawa   650: asked for a very high precision, GMP will not calculate with
        !           651: superfluous digits.  For example, if two low-precision numbers of
        !           652: nearly equal magnitude are added, the precision of the result will be
        !           653: limited to what is required to represent the result accurately.
1.1       maekawa   654:
1.1.1.2 ! maekawa   655:    The GMP floating-point functions are _not_ intended as a smooth
1.1       maekawa   656: extension to the IEEE P754 arithmetic.  Specifically, the results
                    657: obtained on one computer often differs from the results obtained on a
                    658: computer with a different word size.
                    659:
                    660: * Menu:
                    661:
                    662: * Initializing Floats::
                    663: * Assigning Floats::
                    664: * Simultaneous Float Init & Assign::
                    665: * Converting Floats::
                    666: * Float Arithmetic::
                    667: * Float Comparison::
                    668: * I/O of Floats::
                    669: * Miscellaneous Float Functions::
                    670:
                    671: 
1.1.1.2 ! maekawa   672: File: gmp.info,  Node: Initializing Floats,  Next: Assigning Floats,  Prev: Floating-point Functions,  Up: Floating-point Functions
1.1       maekawa   673:
1.1.1.2 ! maekawa   674: Initialization Functions
        !           675: ========================
1.1       maekawa   676:
                    677:  - Function: void mpf_set_default_prec (unsigned long int PREC)
                    678:      Set the default precision to be *at least* PREC bits.  All
                    679:      subsequent calls to `mpf_init' will use this precision, but
                    680:      previously initialized variables are unaffected.
                    681:
                    682:    An `mpf_t' object must be initialized before storing the first value
                    683: in it.  The functions `mpf_init' and `mpf_init2' are used for that
                    684: purpose.
                    685:
                    686:  - Function: void mpf_init (mpf_t X)
                    687:      Initialize X to 0.  Normally, a variable should be initialized
                    688:      once only or at least be cleared, using `mpf_clear', between
                    689:      initializations.  The precision of X is undefined unless a default
                    690:      precision has already been established by a call to
                    691:      `mpf_set_default_prec'.
                    692:
                    693:  - Function: void mpf_init2 (mpf_t X, unsigned long int PREC)
                    694:      Initialize X to 0 and set its precision to be *at least* PREC
                    695:      bits.  Normally, a variable should be initialized once only or at
                    696:      least be cleared, using `mpf_clear', between initializations.
                    697:
                    698:  - Function: void mpf_clear (mpf_t X)
                    699:      Free the space occupied by X.  Make sure to call this function for
                    700:      all `mpf_t' variables when you are done with them.
                    701:
                    702:    Here is an example on how to initialize floating-point variables:
                    703:      {
                    704:        mpf_t x, y;
                    705:        mpf_init (x);                   /* use default precision */
1.1.1.2 ! maekawa   706:        mpf_init2 (y, 256);             /* precision _at least_ 256 bits */
1.1       maekawa   707:        ...
                    708:        /* Unless the program is about to exit, do ... */
                    709:        mpf_clear (x);
                    710:        mpf_clear (y);
                    711:      }
                    712:
                    713:    The following three functions are useful for changing the precision
                    714: during a calculation.  A typical use would be for adjusting the
                    715: precision gradually in iterative algorithms like Newton-Raphson, making
                    716: the computation precision closely match the actual accurate part of the
                    717: numbers.
                    718:
                    719:  - Function: void mpf_set_prec (mpf_t ROP, unsigned long int PREC)
                    720:      Set the precision of ROP to be *at least* PREC bits.  Since
                    721:      changing the precision involves calls to `realloc', this routine
                    722:      should not be called in a tight loop.
                    723:
                    724:  - Function: unsigned long int mpf_get_prec (mpf_t OP)
                    725:      Return the precision actually used for assignments of OP.
                    726:
                    727:  - Function: void mpf_set_prec_raw (mpf_t ROP, unsigned long int PREC)
                    728:      Set the precision of ROP to be *at least* PREC bits.  This is a
                    729:      low-level function that does not change the allocation.  The PREC
                    730:      argument must not be larger that the precision previously returned
                    731:      by `mpf_get_prec'.  It is crucial that the precision of ROP is
1.1.1.2 ! maekawa   732:      ultimately reset to exactly the value returned by `mpf_get_prec'
        !           733:      before the first call to `mpf_set_prec_raw'.
1.1       maekawa   734:
                    735: 
                    736: File: gmp.info,  Node: Assigning Floats,  Next: Simultaneous Float Init & Assign,  Prev: Initializing Floats,  Up: Floating-point Functions
                    737:
                    738: Assignment Functions
1.1.1.2 ! maekawa   739: ====================
1.1       maekawa   740:
                    741:    These functions assign new values to already initialized floats
1.1.1.2 ! maekawa   742: (*note Initializing Floats::).
1.1       maekawa   743:
                    744:  - Function: void mpf_set (mpf_t ROP, mpf_t OP)
                    745:  - Function: void mpf_set_ui (mpf_t ROP, unsigned long int OP)
                    746:  - Function: void mpf_set_si (mpf_t ROP, signed long int OP)
                    747:  - Function: void mpf_set_d (mpf_t ROP, double OP)
                    748:  - Function: void mpf_set_z (mpf_t ROP, mpz_t OP)
                    749:  - Function: void mpf_set_q (mpf_t ROP, mpq_t OP)
                    750:      Set the value of ROP from OP.
                    751:
                    752:  - Function: int mpf_set_str (mpf_t ROP, char *STR, int BASE)
                    753:      Set the value of ROP from the string in STR.  The string is of the
                    754:      form `M@N' or, if the base is 10 or less, alternatively `MeN'.
                    755:      `M' is the mantissa and `N' is the exponent.  The mantissa is
                    756:      always in the specified base.  The exponent is either in the
                    757:      specified base or, if BASE is negative, in decimal.
                    758:
                    759:      The argument BASE may be in the ranges 2 to 36, or -36 to -2.
                    760:      Negative values are used to specify that the exponent is in
                    761:      decimal.
                    762:
                    763:      Unlike the corresponding `mpz' function, the base will not be
                    764:      determined from the leading characters of the string if BASE is 0.
                    765:      This is so that numbers like `0.23' are not interpreted as octal.
                    766:
                    767:      White space is allowed in the string, and is simply ignored.
1.1.1.2 ! maekawa   768:      [This is not really true; white-space is ignored in the beginning
        !           769:      of the string and within the mantissa, but not in other places,
        !           770:      such as after a minus sign or in the exponent.  We are considering
        !           771:      changing the definition of this function, making it fail when
        !           772:      there is any white-space in the input, since that makes a lot of
        !           773:      sense.  Please tell us your opinion about this change.  Do you
        !           774:      really want it to accept "3 14" as meaning 314 as it does now?]
1.1       maekawa   775:
                    776:      This function returns 0 if the entire string up to the '\0' is a
                    777:      valid number in base BASE.  Otherwise it returns -1.
                    778:
1.1.1.2 ! maekawa   779:  - Function: void mpf_swap (mpf_t ROP1, mpf_t ROP2)
        !           780:      Swap the values ROP1 and ROP2 efficiently.
        !           781:
1.1       maekawa   782: 
                    783: File: gmp.info,  Node: Simultaneous Float Init & Assign,  Next: Converting Floats,  Prev: Assigning Floats,  Up: Floating-point Functions
                    784:
                    785: Combined Initialization and Assignment Functions
1.1.1.2 ! maekawa   786: ================================================
1.1       maekawa   787:
1.1.1.2 ! maekawa   788:    For convenience, GMP provides a parallel series of
        !           789: initialize-and-set functions which initialize the output and then store
        !           790: the value there.  These functions' names have the form `mpf_init_set...'
1.1       maekawa   791:
                    792:    Once the float has been initialized by any of the `mpf_init_set...'
                    793: functions, it can be used as the source or destination operand for the
                    794: ordinary float functions.  Don't use an initialize-and-set function on
                    795: a variable already initialized!
                    796:
                    797:  - Function: void mpf_init_set (mpf_t ROP, mpf_t OP)
                    798:  - Function: void mpf_init_set_ui (mpf_t ROP, unsigned long int OP)
                    799:  - Function: void mpf_init_set_si (mpf_t ROP, signed long int OP)
                    800:  - Function: void mpf_init_set_d (mpf_t ROP, double OP)
                    801:      Initialize ROP and set its value from OP.
                    802:
                    803:      The precision of ROP will be taken from the active default
                    804:      precision, as set by `mpf_set_default_prec'.
                    805:
                    806:  - Function: int mpf_init_set_str (mpf_t ROP, char *STR, int BASE)
                    807:      Initialize ROP and set its value from the string in STR.  See
                    808:      `mpf_set_str' above for details on the assignment operation.
                    809:
                    810:      Note that ROP is initialized even if an error occurs.  (I.e., you
                    811:      have to call `mpf_clear' for it.)
                    812:
                    813:      The precision of ROP will be taken from the active default
                    814:      precision, as set by `mpf_set_default_prec'.
                    815:
                    816: 
                    817: File: gmp.info,  Node: Converting Floats,  Next: Float Arithmetic,  Prev: Simultaneous Float Init & Assign,  Up: Floating-point Functions
                    818:
                    819: Conversion Functions
                    820: ====================
                    821:
                    822:  - Function: double mpf_get_d (mpf_t OP)
                    823:      Convert OP to a double.
                    824:
                    825:  - Function: char * mpf_get_str (char *STR, mp_exp_t *EXPPTR, int BASE,
                    826:           size_t N_DIGITS, mpf_t OP)
                    827:      Convert OP to a string of digits in base BASE.  The base may vary
                    828:      from 2 to 36.  Generate at most N_DIGITS significant digits, or if
                    829:      N_DIGITS is 0, the maximum number of digits accurately
                    830:      representable by OP.
                    831:
1.1.1.2 ! maekawa   832:      If STR is `NULL', space for the mantissa is allocated using the
        !           833:      default allocation function.
1.1       maekawa   834:
1.1.1.2 ! maekawa   835:      If STR is not `NULL', it should point to a block of storage enough
1.1       maekawa   836:      large for the mantissa, i.e., N_DIGITS + 2.  The two extra bytes
                    837:      are for a possible minus sign, and for the terminating null
                    838:      character.
                    839:
                    840:      The exponent is written through the pointer EXPPTR.
                    841:
                    842:      If N_DIGITS is 0, the maximum number of digits meaningfully
                    843:      achievable from the precision of OP will be generated.  Note that
                    844:      the space requirements for STR in this case will be impossible for
1.1.1.2 ! maekawa   845:      the user to predetermine.  Therefore, you need to pass `NULL' for
1.1       maekawa   846:      the string argument whenever N_DIGITS is 0.
                    847:
                    848:      The generated string is a fraction, with an implicit radix point
                    849:      immediately to the left of the first digit.  For example, the
                    850:      number 3.1416 would be returned as "31416" in the string and 1
                    851:      written at EXPPTR.
                    852:
1.1.1.2 ! maekawa   853:      A pointer to the result string is returned.  This pointer will
        !           854:      will either equal STR, or if that is `NULL', will point to the
        !           855:      allocated storage.
        !           856:
1.1       maekawa   857: 
                    858: File: gmp.info,  Node: Float Arithmetic,  Next: Float Comparison,  Prev: Converting Floats,  Up: Floating-point Functions
                    859:
                    860: Arithmetic Functions
                    861: ====================
                    862:
                    863:  - Function: void mpf_add (mpf_t ROP, mpf_t OP1, mpf_t OP2)
                    864:  - Function: void mpf_add_ui (mpf_t ROP, mpf_t OP1, unsigned long int
                    865:           OP2)
                    866:      Set ROP to OP1 + OP2.
                    867:
                    868:  - Function: void mpf_sub (mpf_t ROP, mpf_t OP1, mpf_t OP2)
                    869:  - Function: void mpf_ui_sub (mpf_t ROP, unsigned long int OP1, mpf_t
                    870:           OP2)
                    871:  - Function: void mpf_sub_ui (mpf_t ROP, mpf_t OP1, unsigned long int
                    872:           OP2)
                    873:      Set ROP to OP1 - OP2.
                    874:
                    875:  - Function: void mpf_mul (mpf_t ROP, mpf_t OP1, mpf_t OP2)
                    876:  - Function: void mpf_mul_ui (mpf_t ROP, mpf_t OP1, unsigned long int
                    877:           OP2)
                    878:      Set ROP to OP1 times OP2.
                    879:
                    880:    Division is undefined if the divisor is zero, and passing a zero
                    881: divisor to the divide functions will make these functions intentionally
1.1.1.2 ! maekawa   882: divide by zero.  This lets the user handle arithmetic exceptions in
        !           883: these functions in the same manner as other arithmetic exceptions.
1.1       maekawa   884:
                    885:  - Function: void mpf_div (mpf_t ROP, mpf_t OP1, mpf_t OP2)
                    886:  - Function: void mpf_ui_div (mpf_t ROP, unsigned long int OP1, mpf_t
                    887:           OP2)
                    888:  - Function: void mpf_div_ui (mpf_t ROP, mpf_t OP1, unsigned long int
                    889:           OP2)
                    890:      Set ROP to OP1/OP2.
                    891:
                    892:  - Function: void mpf_sqrt (mpf_t ROP, mpf_t OP)
                    893:  - Function: void mpf_sqrt_ui (mpf_t ROP, unsigned long int OP)
                    894:      Set ROP to the square root of OP.
                    895:
1.1.1.2 ! maekawa   896:  - Function: void mpf_pow_ui (mpf_t ROP, mpf_t OP1, unsigned long int
        !           897:           OP2)
        !           898:      Set ROP to OP1 raised to the power OP2.
        !           899:
1.1       maekawa   900:  - Function: void mpf_neg (mpf_t ROP, mpf_t OP)
                    901:      Set ROP to -OP.
                    902:
                    903:  - Function: void mpf_abs (mpf_t ROP, mpf_t OP)
                    904:      Set ROP to the absolute value of OP.
                    905:
                    906:  - Function: void mpf_mul_2exp (mpf_t ROP, mpf_t OP1, unsigned long int
                    907:           OP2)
                    908:      Set ROP to OP1 times 2 raised to OP2.
                    909:
                    910:  - Function: void mpf_div_2exp (mpf_t ROP, mpf_t OP1, unsigned long int
                    911:           OP2)
                    912:      Set ROP to OP1 divided by 2 raised to OP2.
                    913:
                    914: 
                    915: File: gmp.info,  Node: Float Comparison,  Next: I/O of Floats,  Prev: Float Arithmetic,  Up: Floating-point Functions
                    916:
                    917: Comparison Functions
                    918: ====================
                    919:
                    920:  - Function: int mpf_cmp (mpf_t OP1, mpf_t OP2)
                    921:  - Function: int mpf_cmp_ui (mpf_t OP1, unsigned long int OP2)
                    922:  - Function: int mpf_cmp_si (mpf_t OP1, signed long int OP2)
                    923:      Compare OP1 and OP2.  Return a positive value if OP1 > OP2, zero
                    924:      if OP1 = OP2, and a negative value if OP1 < OP2.
                    925:
                    926:  - Function: int mpf_eq (mpf_t OP1, mpf_t OP2, unsigned long int op3)
                    927:      Return non-zero if the first OP3 bits of OP1 and OP2 are equal,
                    928:      zero otherwise.  I.e., test of OP1 and OP2 are approximately equal.
                    929:
                    930:  - Function: void mpf_reldiff (mpf_t ROP, mpf_t OP1, mpf_t OP2)
                    931:      Compute the relative difference between OP1 and OP2 and store the
                    932:      result in ROP.
                    933:
                    934:  - Macro: int mpf_sgn (mpf_t OP)
                    935:      Return +1 if OP > 0, 0 if OP = 0, and -1 if OP < 0.
                    936:
                    937:      This function is actually implemented as a macro.  It evaluates its
                    938:      arguments multiple times.
                    939:
                    940: 
                    941: File: gmp.info,  Node: I/O of Floats,  Next: Miscellaneous Float Functions,  Prev: Float Comparison,  Up: Floating-point Functions
                    942:
                    943: Input and Output Functions
                    944: ==========================
                    945:
                    946:    Functions that perform input from a stdio stream, and functions that
1.1.1.2 ! maekawa   947: output to a stdio stream.  Passing a `NULL' pointer for a STREAM
        !           948: argument to any of these functions will make them read from `stdin' and
        !           949: write to `stdout', respectively.
1.1       maekawa   950:
                    951:    When using any of these functions, it is a good idea to include
                    952: `stdio.h' before `gmp.h', since that will allow `gmp.h' to define
                    953: prototypes for these functions.
                    954:
                    955:  - Function: size_t mpf_out_str (FILE *STREAM, int BASE, size_t
                    956:           N_DIGITS, mpf_t OP)
                    957:      Output OP on stdio stream STREAM, as a string of digits in base
                    958:      BASE.  The base may vary from 2 to 36.  Print at most N_DIGITS
                    959:      significant digits, or if N_DIGITS is 0, the maximum number of
                    960:      digits accurately representable by OP.
                    961:
                    962:      In addition to the significant digits, a leading `0.' and a
                    963:      trailing exponent, in the form `eNNN', are printed.  If BASE is
                    964:      greater than 10, `@' will be used instead of `e' as exponent
                    965:      delimiter.
                    966:
                    967:      Return the number of bytes written, or if an error occurred,
                    968:      return 0.
                    969:
                    970:  - Function: size_t mpf_inp_str (mpf_t ROP, FILE *STREAM, int BASE)
                    971:      Input a string in base BASE from stdio stream STREAM, and put the
                    972:      read float in ROP.  The string is of the form `M@N' or, if the
                    973:      base is 10 or less, alternatively `MeN'.  `M' is the mantissa and
                    974:      `N' is the exponent.  The mantissa is always in the specified
                    975:      base.  The exponent is either in the specified base or, if BASE is
                    976:      negative, in decimal.
                    977:
                    978:      The argument BASE may be in the ranges 2 to 36, or -36 to -2.
                    979:      Negative values are used to specify that the exponent is in
                    980:      decimal.
                    981:
                    982:      Unlike the corresponding `mpz' function, the base will not be
                    983:      determined from the leading characters of the string if BASE is 0.
                    984:      This is so that numbers like `0.23' are not interpreted as octal.
                    985:
                    986:      Return the number of bytes read, or if an error occurred, return 0.
                    987:
                    988: 
                    989: File: gmp.info,  Node: Miscellaneous Float Functions,  Prev: I/O of Floats,  Up: Floating-point Functions
                    990:
                    991: Miscellaneous Functions
                    992: =======================
                    993:
1.1.1.2 ! maekawa   994:  - Function: void mpf_ceil (mpf_t ROP, mpf_t OP)
        !           995:  - Function: void mpf_floor (mpf_t ROP, mpf_t OP)
        !           996:  - Function: void mpf_trunc (mpf_t ROP, mpf_t OP)
        !           997:      Set ROP to OP rounded to an integer.  `mpf_ceil' rounds to the
        !           998:      next higher integer, `mpf_floor' to the next lower, and
        !           999:      `mpf_trunc' to the integer towards zero.
        !          1000:
        !          1001:  - Function: void mpf_urandomb (mpf_t ROP, gmp_randstate_t STATE,
        !          1002:           unsigned long int NBITS)
        !          1003:      Generate a uniformly distributed random float in ROP, such that 0
        !          1004:      <= ROP < 1, with NBITS significant bits in the mantissa.
        !          1005:
        !          1006:      The variable STATE must be initialized by calling one of the
        !          1007:      `gmp_randinit' functions (*Note Random State Initialization::)
        !          1008:      before invoking this function.
        !          1009:
1.1       maekawa  1010:  - Function: void mpf_random2 (mpf_t ROP, mp_size_t MAX_SIZE, mp_exp_t
                   1011:           MAX_EXP)
                   1012:      Generate a random float of at most MAX_SIZE limbs, with long
                   1013:      strings of zeros and ones in the binary representation.  The
                   1014:      exponent of the number is in the interval -EXP to EXP.  This
                   1015:      function is useful for testing functions and algorithms, since
                   1016:      this kind of random numbers have proven to be more likely to
                   1017:      trigger corner-case bugs.  Negative random numbers are generated
                   1018:      when MAX_SIZE is negative.
                   1019:

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