]> git.xonotic.org Git - xonotic/xonotic.git/blob - misc/builddeps/linux64/gmp/share/info/gmp.info-2
Recompile linux64 GMP and d0_blind_id --with-pic --enable-static --disable-shared.
[xonotic/xonotic.git] / misc / builddeps / linux64 / gmp / share / info / gmp.info-2
1 This is gmp.info, produced by makeinfo version 6.7 from gmp.texi.
2
3 This manual describes how to install and use the GNU multiple precision
4 arithmetic library, version 6.2.1.
5
6    Copyright 1991, 1993-2016, 2018-2020 Free Software Foundation, Inc.
7
8    Permission is granted to copy, distribute and/or modify this document
9 under the terms of the GNU Free Documentation License, Version 1.3 or
10 any later version published by the Free Software Foundation; with no
11 Invariant Sections, with the Front-Cover Texts being "A GNU Manual", and
12 with the Back-Cover Texts being "You have freedom to copy and modify
13 this GNU Manual, like GNU software".  A copy of the license is included
14 in *note GNU Free Documentation License::.
15 INFO-DIR-SECTION GNU libraries
16 START-INFO-DIR-ENTRY
17 * gmp: (gmp).                   GNU Multiple Precision Arithmetic Library.
18 END-INFO-DIR-ENTRY
19
20 \1f
21 File: gmp.info,  Node: Exact Remainder,  Next: Small Quotient Division,  Prev: Exact Division,  Up: Division Algorithms
22
23 15.2.6 Exact Remainder
24 ----------------------
25
26 If the exact division algorithm is done with a full subtraction at each
27 stage and the dividend isn't a multiple of the divisor, then low zero
28 limbs are produced but with a remainder in the high limbs.  For dividend
29 a, divisor d, quotient q, and b = 2^mp_bits_per_limb, this remainder r
30 is of the form
31
32      a = q*d + r*b^n
33
34    n represents the number of zero limbs produced by the subtractions,
35 that being the number of limbs produced for q.  r will be in the range
36 0<=r<d and can be viewed as a remainder, but one shifted up by a factor
37 of b^n.
38
39    Carrying out full subtractions at each stage means the same number of
40 cross products must be done as a normal division, but there's still some
41 single limb divisions saved.  When d is a single limb some
42 simplifications arise, providing good speedups on a number of
43 processors.
44
45    The functions 'mpn_divexact_by3', 'mpn_modexact_1_odd' and the
46 internal 'mpn_redc_X' functions differ subtly in how they return r,
47 leading to some negations in the above formula, but all are essentially
48 the same.
49
50    Clearly r is zero when a is a multiple of d, and this leads to
51 divisibility or congruence tests which are potentially more efficient
52 than a normal division.
53
54    The factor of b^n on r can be ignored in a GCD when d is odd, hence
55 the use of 'mpn_modexact_1_odd' by 'mpn_gcd_1' and 'mpz_kronecker_ui'
56 etc (*note Greatest Common Divisor Algorithms::).
57
58    Montgomery's REDC method for modular multiplications uses operands of
59 the form of x*b^-n and y*b^-n and on calculating (x*b^-n)*(y*b^-n) uses
60 the factor of b^n in the exact remainder to reach a product in the same
61 form (x*y)*b^-n (*note Modular Powering Algorithm::).
62
63    Notice that r generally gives no useful information about the
64 ordinary remainder a mod d since b^n mod d could be anything.  If
65 however b^n == 1 mod d, then r is the negative of the ordinary
66 remainder.  This occurs whenever d is a factor of b^n-1, as for example
67 with 3 in 'mpn_divexact_by3'.  For a 32 or 64 bit limb other such
68 factors include 5, 17 and 257, but no particular use has been found for
69 this.
70
71 \1f
72 File: gmp.info,  Node: Small Quotient Division,  Prev: Exact Remainder,  Up: Division Algorithms
73
74 15.2.7 Small Quotient Division
75 ------------------------------
76
77 An NxM division where the number of quotient limbs Q=N-M is small can be
78 optimized somewhat.
79
80    An ordinary basecase division normalizes the divisor by shifting it
81 to make the high bit set, shifting the dividend accordingly, and
82 shifting the remainder back down at the end of the calculation.  This is
83 wasteful if only a few quotient limbs are to be formed.  Instead a
84 division of just the top 2*Q limbs of the dividend by the top Q limbs of
85 the divisor can be used to form a trial quotient.  This requires only
86 those limbs normalized, not the whole of the divisor and dividend.
87
88    A multiply and subtract then applies the trial quotient to the M-Q
89 unused limbs of the divisor and N-Q dividend limbs (which includes Q
90 limbs remaining from the trial quotient division).  The starting trial
91 quotient can be 1 or 2 too big, but all cases of 2 too big and most
92 cases of 1 too big are detected by first comparing the most significant
93 limbs that will arise from the subtraction.  An addback is done if the
94 quotient still turns out to be 1 too big.
95
96    This whole procedure is essentially the same as one step of the
97 basecase algorithm done in a Q limb base, though with the trial quotient
98 test done only with the high limbs, not an entire Q limb "digit"
99 product.  The correctness of this weaker test can be established by
100 following the argument of Knuth section 4.3.1 exercise 20 but with the
101 v2*q>b*r+u2 condition appropriately relaxed.
102
103 \1f
104 File: gmp.info,  Node: Greatest Common Divisor Algorithms,  Next: Powering Algorithms,  Prev: Division Algorithms,  Up: Algorithms
105
106 15.3 Greatest Common Divisor
107 ============================
108
109 * Menu:
110
111 * Binary GCD::
112 * Lehmer's Algorithm::
113 * Subquadratic GCD::
114 * Extended GCD::
115 * Jacobi Symbol::
116
117 \1f
118 File: gmp.info,  Node: Binary GCD,  Next: Lehmer's Algorithm,  Prev: Greatest Common Divisor Algorithms,  Up: Greatest Common Divisor Algorithms
119
120 15.3.1 Binary GCD
121 -----------------
122
123 At small sizes GMP uses an O(N^2) binary style GCD.  This is described
124 in many textbooks, for example Knuth section 4.5.2 algorithm B.  It
125 simply consists of successively reducing odd operands a and b using
126
127      a,b = abs(a-b),min(a,b)
128      strip factors of 2 from a
129
130    The Euclidean GCD algorithm, as per Knuth algorithms E and A,
131 repeatedly computes the quotient q = floor(a/b) and replaces a,b by v, u
132 - q v.  The binary algorithm has so far been found to be faster than the
133 Euclidean algorithm everywhere.  One reason the binary method does well
134 is that the implied quotient at each step is usually small, so often
135 only one or two subtractions are needed to get the same effect as a
136 division.  Quotients 1, 2 and 3 for example occur 67.7% of the time, see
137 Knuth section 4.5.3 Theorem E.
138
139    When the implied quotient is large, meaning b is much smaller than a,
140 then a division is worthwhile.  This is the basis for the initial a mod
141 b reductions in 'mpn_gcd' and 'mpn_gcd_1' (the latter for both Nx1 and
142 1x1 cases).  But after that initial reduction, big quotients occur too
143 rarely to make it worth checking for them.
144
145
146    The final 1x1 GCD in 'mpn_gcd_1' is done in the generic C code as
147 described above.  For two N-bit operands, the algorithm takes about 0.68
148 iterations per bit.  For optimum performance some attention needs to be
149 paid to the way the factors of 2 are stripped from a.
150
151    Firstly it may be noted that in twos complement the number of low
152 zero bits on a-b is the same as b-a, so counting or testing can begin on
153 a-b without waiting for abs(a-b) to be determined.
154
155    A loop stripping low zero bits tends not to branch predict well,
156 since the condition is data dependent.  But on average there's only a
157 few low zeros, so an option is to strip one or two bits arithmetically
158 then loop for more (as done for AMD K6).  Or use a lookup table to get a
159 count for several bits then loop for more (as done for AMD K7).  An
160 alternative approach is to keep just one of a or b odd and iterate
161
162      a,b = abs(a-b), min(a,b)
163      a = a/2 if even
164      b = b/2 if even
165
166    This requires about 1.25 iterations per bit, but stripping of a
167 single bit at each step avoids any branching.  Repeating the bit strip
168 reduces to about 0.9 iterations per bit, which may be a worthwhile
169 tradeoff.
170
171    Generally with the above approaches a speed of perhaps 6 cycles per
172 bit can be achieved, which is still not terribly fast with for instance
173 a 64-bit GCD taking nearly 400 cycles.  It's this sort of time which
174 means it's not usually advantageous to combine a set of divisibility
175 tests into a GCD.
176
177    Currently, the binary algorithm is used for GCD only when N < 3.
178
179 \1f
180 File: gmp.info,  Node: Lehmer's Algorithm,  Next: Subquadratic GCD,  Prev: Binary GCD,  Up: Greatest Common Divisor Algorithms
181
182 15.3.2 Lehmer's algorithm
183 -------------------------
184
185 Lehmer's improvement of the Euclidean algorithms is based on the
186 observation that the initial part of the quotient sequence depends only
187 on the most significant parts of the inputs.  The variant of Lehmer's
188 algorithm used in GMP splits off the most significant two limbs, as
189 suggested, e.g., in "A Double-Digit Lehmer-Euclid Algorithm" by Jebelean
190 (*note References::).  The quotients of two double-limb inputs are
191 collected as a 2 by 2 matrix with single-limb elements.  This is done by
192 the function 'mpn_hgcd2'.  The resulting matrix is applied to the inputs
193 using 'mpn_mul_1' and 'mpn_submul_1'.  Each iteration usually reduces
194 the inputs by almost one limb.  In the rare case of a large quotient, no
195 progress can be made by examining just the most significant two limbs,
196 and the quotient is computed using plain division.
197
198    The resulting algorithm is asymptotically O(N^2), just as the
199 Euclidean algorithm and the binary algorithm.  The quadratic part of the
200 work are the calls to 'mpn_mul_1' and 'mpn_submul_1'.  For small sizes,
201 the linear work is also significant.  There are roughly N calls to the
202 'mpn_hgcd2' function.  This function uses a couple of important
203 optimizations:
204
205    * It uses the same relaxed notion of correctness as 'mpn_hgcd' (see
206      next section).  This means that when called with the most
207      significant two limbs of two large numbers, the returned matrix
208      does not always correspond exactly to the initial quotient sequence
209      for the two large numbers; the final quotient may sometimes be one
210      off.
211
212    * It takes advantage of the fact the quotients are usually small.
213      The division operator is not used, since the corresponding
214      assembler instruction is very slow on most architectures.  (This
215      code could probably be improved further, it uses many branches that
216      are unfriendly to prediction).
217
218    * It switches from double-limb calculations to single-limb
219      calculations half-way through, when the input numbers have been
220      reduced in size from two limbs to one and a half.
221
222 \1f
223 File: gmp.info,  Node: Subquadratic GCD,  Next: Extended GCD,  Prev: Lehmer's Algorithm,  Up: Greatest Common Divisor Algorithms
224
225 15.3.3 Subquadratic GCD
226 -----------------------
227
228 For inputs larger than 'GCD_DC_THRESHOLD', GCD is computed via the HGCD
229 (Half GCD) function, as a generalization to Lehmer's algorithm.
230
231    Let the inputs a,b be of size N limbs each.  Put S = floor(N/2) + 1.
232 Then HGCD(a,b) returns a transformation matrix T with non-negative
233 elements, and reduced numbers (c;d) = T^{-1} (a;b).  The reduced numbers
234 c,d must be larger than S limbs, while their difference abs(c-d) must
235 fit in S limbs.  The matrix elements will also be of size roughly N/2.
236
237    The HGCD base case uses Lehmer's algorithm, but with the above stop
238 condition that returns reduced numbers and the corresponding
239 transformation matrix half-way through.  For inputs larger than
240 'HGCD_THRESHOLD', HGCD is computed recursively, using the divide and
241 conquer algorithm in "On Schönhage's algorithm and subquadratic integer
242 GCD computation" by Möller (*note References::).  The recursive
243 algorithm consists of these main steps.
244
245    * Call HGCD recursively, on the most significant N/2 limbs.  Apply
246      the resulting matrix T_1 to the full numbers, reducing them to a
247      size just above 3N/2.
248
249    * Perform a small number of division or subtraction steps to reduce
250      the numbers to size below 3N/2.  This is essential mainly for the
251      unlikely case of large quotients.
252
253    * Call HGCD recursively, on the most significant N/2 limbs of the
254      reduced numbers.  Apply the resulting matrix T_2 to the full
255      numbers, reducing them to a size just above N/2.
256
257    * Compute T = T_1 T_2.
258
259    * Perform a small number of division and subtraction steps to satisfy
260      the requirements, and return.
261
262    GCD is then implemented as a loop around HGCD, similarly to Lehmer's
263 algorithm.  Where Lehmer repeatedly chops off the top two limbs, calls
264 'mpn_hgcd2', and applies the resulting matrix to the full numbers, the
265 sub-quadratic GCD chops off the most significant third of the limbs (the
266 proportion is a tuning parameter, and 1/3 seems to be more efficient
267 than, e.g, 1/2), calls 'mpn_hgcd', and applies the resulting matrix.
268 Once the input numbers are reduced to size below 'GCD_DC_THRESHOLD',
269 Lehmer's algorithm is used for the rest of the work.
270
271    The asymptotic running time of both HGCD and GCD is O(M(N)*log(N)),
272 where M(N) is the time for multiplying two N-limb numbers.
273
274 \1f
275 File: gmp.info,  Node: Extended GCD,  Next: Jacobi Symbol,  Prev: Subquadratic GCD,  Up: Greatest Common Divisor Algorithms
276
277 15.3.4 Extended GCD
278 -------------------
279
280 The extended GCD function, or GCDEXT, calculates gcd(a,b) and also
281 cofactors x and y satisfying a*x+b*y=gcd(a,b).  All the algorithms used
282 for plain GCD are extended to handle this case.  The binary algorithm is
283 used only for single-limb GCDEXT. Lehmer's algorithm is used for sizes
284 up to 'GCDEXT_DC_THRESHOLD'.  Above this threshold, GCDEXT is
285 implemented as a loop around HGCD, but with more book-keeping to keep
286 track of the cofactors.  This gives the same asymptotic running time as
287 for GCD and HGCD, O(M(N)*log(N))
288
289    One difference to plain GCD is that while the inputs a and b are
290 reduced as the algorithm proceeds, the cofactors x and y grow in size.
291 This makes the tuning of the chopping-point more difficult.  The current
292 code chops off the most significant half of the inputs for the call to
293 HGCD in the first iteration, and the most significant two thirds for the
294 remaining calls.  This strategy could surely be improved.  Also the stop
295 condition for the loop, where Lehmer's algorithm is invoked once the
296 inputs are reduced below 'GCDEXT_DC_THRESHOLD', could maybe be improved
297 by taking into account the current size of the cofactors.
298
299 \1f
300 File: gmp.info,  Node: Jacobi Symbol,  Prev: Extended GCD,  Up: Greatest Common Divisor Algorithms
301
302 15.3.5 Jacobi Symbol
303 --------------------
304
305 Jacobi symbol (A/B)
306
307    Initially if either operand fits in a single limb, a reduction is
308 done with either 'mpn_mod_1' or 'mpn_modexact_1_odd', followed by the
309 binary algorithm on a single limb.  The binary algorithm is well suited
310 to a single limb, and the whole calculation in this case is quite
311 efficient.
312
313    For inputs larger than 'GCD_DC_THRESHOLD', 'mpz_jacobi',
314 'mpz_legendre' and 'mpz_kronecker' are computed via the HGCD (Half GCD)
315 function, as a generalization to Lehmer's algorithm.
316
317    Most GCD algorithms reduce a and b by repeatatily computing the
318 quotient q = floor(a/b) and iteratively replacing
319
320    a, b = b, a - q * b
321
322    Different algorithms use different methods for calculating q, but the
323 core algorithm is the same if we use *note Lehmer's Algorithm:: or *note
324 HGCD: Subquadratic GCD.
325
326    At each step it is possible to compute if the reduction inverts the
327 Jacobi symbol based on the two least significant bits of A and B.  For
328 more details see "Efficient computation of the Jacobi symbol" by Möller
329 (*note References::).
330
331    A small set of bits is thus used to track state
332    * current sign of result (1 bit)
333
334    * two least significant bits of A and B (4 bits)
335
336    * a pointer to which input is currently the denominator (1 bit)
337
338    In all the routines sign changes for the result are accumulated using
339 fast bit twiddling which avoids conditional jumps.
340
341    The final result is calculated after verifying the inputs are coprime
342 (GCD = 1) by raising (-1)^e
343
344    Much of the HGCD code is shared directly with the HGCD
345 implementations, such as the 2x2 matrix calculation, *Note Lehmer's
346 Algorithm:: basecase and 'GCD_DC_THRESHOLD'.
347
348    The asymptotic running time is O(M(N)*log(N)), where M(N) is the time
349 for multiplying two N-limb numbers.
350
351 \1f
352 File: gmp.info,  Node: Powering Algorithms,  Next: Root Extraction Algorithms,  Prev: Greatest Common Divisor Algorithms,  Up: Algorithms
353
354 15.4 Powering Algorithms
355 ========================
356
357 * Menu:
358
359 * Normal Powering Algorithm::
360 * Modular Powering Algorithm::
361
362 \1f
363 File: gmp.info,  Node: Normal Powering Algorithm,  Next: Modular Powering Algorithm,  Prev: Powering Algorithms,  Up: Powering Algorithms
364
365 15.4.1 Normal Powering
366 ----------------------
367
368 Normal 'mpz' or 'mpf' powering uses a simple binary algorithm,
369 successively squaring and then multiplying by the base when a 1 bit is
370 seen in the exponent, as per Knuth section 4.6.3.  The "left to right"
371 variant described there is used rather than algorithm A, since it's just
372 as easy and can be done with somewhat less temporary memory.
373
374 \1f
375 File: gmp.info,  Node: Modular Powering Algorithm,  Prev: Normal Powering Algorithm,  Up: Powering Algorithms
376
377 15.4.2 Modular Powering
378 -----------------------
379
380 Modular powering is implemented using a 2^k-ary sliding window
381 algorithm, as per "Handbook of Applied Cryptography" algorithm 14.85
382 (*note References::).  k is chosen according to the size of the
383 exponent.  Larger exponents use larger values of k, the choice being
384 made to minimize the average number of multiplications that must
385 supplement the squaring.
386
387    The modular multiplies and squarings use either a simple division or
388 the REDC method by Montgomery (*note References::).  REDC is a little
389 faster, essentially saving N single limb divisions in a fashion similar
390 to an exact remainder (*note Exact Remainder::).
391
392 \1f
393 File: gmp.info,  Node: Root Extraction Algorithms,  Next: Radix Conversion Algorithms,  Prev: Powering Algorithms,  Up: Algorithms
394
395 15.5 Root Extraction Algorithms
396 ===============================
397
398 * Menu:
399
400 * Square Root Algorithm::
401 * Nth Root Algorithm::
402 * Perfect Square Algorithm::
403 * Perfect Power Algorithm::
404
405 \1f
406 File: gmp.info,  Node: Square Root Algorithm,  Next: Nth Root Algorithm,  Prev: Root Extraction Algorithms,  Up: Root Extraction Algorithms
407
408 15.5.1 Square Root
409 ------------------
410
411 Square roots are taken using the "Karatsuba Square Root" algorithm by
412 Paul Zimmermann (*note References::).
413
414    An input n is split into four parts of k bits each, so with b=2^k we
415 have n = a3*b^3 + a2*b^2 + a1*b + a0.  Part a3 must be "normalized" so
416 that either the high or second highest bit is set.  In GMP, k is kept on
417 a limb boundary and the input is left shifted (by an even number of
418 bits) to normalize.
419
420    The square root of the high two parts is taken, by recursive
421 application of the algorithm (bottoming out in a one-limb Newton's
422 method),
423
424      s1,r1 = sqrtrem (a3*b + a2)
425
426    This is an approximation to the desired root and is extended by a
427 division to give s,r,
428
429      q,u = divrem (r1*b + a1, 2*s1)
430      s = s1*b + q
431      r = u*b + a0 - q^2
432
433    The normalization requirement on a3 means at this point s is either
434 correct or 1 too big.  r is negative in the latter case, so
435
436      if r < 0 then
437        r = r + 2*s - 1
438        s = s - 1
439
440    The algorithm is expressed in a divide and conquer form, but as noted
441 in the paper it can also be viewed as a discrete variant of Newton's
442 method, or as a variation on the schoolboy method (no longer taught) for
443 square roots two digits at a time.
444
445    If the remainder r is not required then usually only a few high limbs
446 of r and u need to be calculated to determine whether an adjustment to s
447 is required.  This optimization is not currently implemented.
448
449    In the Karatsuba multiplication range this algorithm is
450 O(1.5*M(N/2)), where M(n) is the time to multiply two numbers of n
451 limbs.  In the FFT multiplication range this grows to a bound of
452 O(6*M(N/2)).  In practice a factor of about 1.5 to 1.8 is found in the
453 Karatsuba and Toom-3 ranges, growing to 2 or 3 in the FFT range.
454
455    The algorithm does all its calculations in integers and the resulting
456 'mpn_sqrtrem' is used for both 'mpz_sqrt' and 'mpf_sqrt'.  The extended
457 precision given by 'mpf_sqrt_ui' is obtained by padding with zero limbs.
458
459 \1f
460 File: gmp.info,  Node: Nth Root Algorithm,  Next: Perfect Square Algorithm,  Prev: Square Root Algorithm,  Up: Root Extraction Algorithms
461
462 15.5.2 Nth Root
463 ---------------
464
465 Integer Nth roots are taken using Newton's method with the following
466 iteration, where A is the input and n is the root to be taken.
467
468               1         A
469      a[i+1] = - * ( --------- + (n-1)*a[i] )
470               n     a[i]^(n-1)
471
472    The initial approximation a[1] is generated bitwise by successively
473 powering a trial root with or without new 1 bits, aiming to be just
474 above the true root.  The iteration converges quadratically when started
475 from a good approximation.  When n is large more initial bits are needed
476 to get good convergence.  The current implementation is not particularly
477 well optimized.
478
479 \1f
480 File: gmp.info,  Node: Perfect Square Algorithm,  Next: Perfect Power Algorithm,  Prev: Nth Root Algorithm,  Up: Root Extraction Algorithms
481
482 15.5.3 Perfect Square
483 ---------------------
484
485 A significant fraction of non-squares can be quickly identified by
486 checking whether the input is a quadratic residue modulo small integers.
487
488    'mpz_perfect_square_p' first tests the input mod 256, which means
489 just examining the low byte.  Only 44 different values occur for squares
490 mod 256, so 82.8% of inputs can be immediately identified as
491 non-squares.
492
493    On a 32-bit system similar tests are done mod 9, 5, 7, 13 and 17, for
494 a total 99.25% of inputs identified as non-squares.  On a 64-bit system
495 97 is tested too, for a total 99.62%.
496
497    These moduli are chosen because they're factors of 2^24-1 (or 2^48-1
498 for 64-bits), and such a remainder can be quickly taken just using
499 additions (see 'mpn_mod_34lsub1').
500
501    When nails are in use moduli are instead selected by the 'gen-psqr.c'
502 program and applied with an 'mpn_mod_1'.  The same 2^24-1 or 2^48-1
503 could be done with nails using some extra bit shifts, but this is not
504 currently implemented.
505
506    In any case each modulus is applied to the 'mpn_mod_34lsub1' or
507 'mpn_mod_1' remainder and a table lookup identifies non-squares.  By
508 using a "modexact" style calculation, and suitably permuted tables, just
509 one multiply each is required, see the code for details.  Moduli are
510 also combined to save operations, so long as the lookup tables don't
511 become too big.  'gen-psqr.c' does all the pre-calculations.
512
513    A square root must still be taken for any value that passes these
514 tests, to verify it's really a square and not one of the small fraction
515 of non-squares that get through (i.e. a pseudo-square to all the tested
516 bases).
517
518    Clearly more residue tests could be done, 'mpz_perfect_square_p' only
519 uses a compact and efficient set.  Big inputs would probably benefit
520 from more residue testing, small inputs might be better off with less.
521 The assumed distribution of squares versus non-squares in the input
522 would affect such considerations.
523
524 \1f
525 File: gmp.info,  Node: Perfect Power Algorithm,  Prev: Perfect Square Algorithm,  Up: Root Extraction Algorithms
526
527 15.5.4 Perfect Power
528 --------------------
529
530 Detecting perfect powers is required by some factorization algorithms.
531 Currently 'mpz_perfect_power_p' is implemented using repeated Nth root
532 extractions, though naturally only prime roots need to be considered.
533 (*Note Nth Root Algorithm::.)
534
535    If a prime divisor p with multiplicity e can be found, then only
536 roots which are divisors of e need to be considered, much reducing the
537 work necessary.  To this end divisibility by a set of small primes is
538 checked.
539
540 \1f
541 File: gmp.info,  Node: Radix Conversion Algorithms,  Next: Other Algorithms,  Prev: Root Extraction Algorithms,  Up: Algorithms
542
543 15.6 Radix Conversion
544 =====================
545
546 Radix conversions are less important than other algorithms.  A program
547 dominated by conversions should probably use a different data
548 representation.
549
550 * Menu:
551
552 * Binary to Radix::
553 * Radix to Binary::
554
555 \1f
556 File: gmp.info,  Node: Binary to Radix,  Next: Radix to Binary,  Prev: Radix Conversion Algorithms,  Up: Radix Conversion Algorithms
557
558 15.6.1 Binary to Radix
559 ----------------------
560
561 Conversions from binary to a power-of-2 radix use a simple and fast O(N)
562 bit extraction algorithm.
563
564    Conversions from binary to other radices use one of two algorithms.
565 Sizes below 'GET_STR_PRECOMPUTE_THRESHOLD' use a basic O(N^2) method.
566 Repeated divisions by b^n are made, where b is the radix and n is the
567 biggest power that fits in a limb.  But instead of simply using the
568 remainder r from such divisions, an extra divide step is done to give a
569 fractional limb representing r/b^n.  The digits of r can then be
570 extracted using multiplications by b rather than divisions.  Special
571 case code is provided for decimal, allowing multiplications by 10 to
572 optimize to shifts and adds.
573
574    Above 'GET_STR_PRECOMPUTE_THRESHOLD' a sub-quadratic algorithm is
575 used.  For an input t, powers b^(n*2^i) of the radix are calculated,
576 until a power between t and sqrt(t) is reached.  t is then divided by
577 that largest power, giving a quotient which is the digits above that
578 power, and a remainder which is those below.  These two parts are in
579 turn divided by the second highest power, and so on recursively.  When a
580 piece has been divided down to less than 'GET_STR_DC_THRESHOLD' limbs,
581 the basecase algorithm described above is used.
582
583    The advantage of this algorithm is that big divisions can make use of
584 the sub-quadratic divide and conquer division (*note Divide and Conquer
585 Division::), and big divisions tend to have less overheads than lots of
586 separate single limb divisions anyway.  But in any case the cost of
587 calculating the powers b^(n*2^i) must first be overcome.
588
589    'GET_STR_PRECOMPUTE_THRESHOLD' and 'GET_STR_DC_THRESHOLD' represent
590 the same basic thing, the point where it becomes worth doing a big
591 division to cut the input in half.  'GET_STR_PRECOMPUTE_THRESHOLD'
592 includes the cost of calculating the radix power required, whereas
593 'GET_STR_DC_THRESHOLD' assumes that's already available, which is the
594 case when recursing.
595
596    Since the base case produces digits from least to most significant
597 but they want to be stored from most to least, it's necessary to
598 calculate in advance how many digits there will be, or at least be sure
599 not to underestimate that.  For GMP the number of input bits is
600 multiplied by 'chars_per_bit_exactly' from 'mp_bases', rounding up.  The
601 result is either correct or one too big.
602
603    Examining some of the high bits of the input could increase the
604 chance of getting the exact number of digits, but an exact result every
605 time would not be practical, since in general the difference between
606 numbers 100... and 99... is only in the last few bits and the work to
607 identify 99... might well be almost as much as a full conversion.
608
609    The r/b^n scheme described above for using multiplications to bring
610 out digits might be useful for more than a single limb.  Some brief
611 experiments with it on the base case when recursing didn't give a
612 noticeable improvement, but perhaps that was only due to the
613 implementation.  Something similar would work for the sub-quadratic
614 divisions too, though there would be the cost of calculating a bigger
615 radix power.
616
617    Another possible improvement for the sub-quadratic part would be to
618 arrange for radix powers that balanced the sizes of quotient and
619 remainder produced, i.e. the highest power would be an b^(n*k)
620 approximately equal to sqrt(t), not restricted to a 2^i factor.  That
621 ought to smooth out a graph of times against sizes, but may or may not
622 be a net speedup.
623
624 \1f
625 File: gmp.info,  Node: Radix to Binary,  Prev: Binary to Radix,  Up: Radix Conversion Algorithms
626
627 15.6.2 Radix to Binary
628 ----------------------
629
630 *This section needs to be rewritten, it currently describes the
631 algorithms used before GMP 4.3.*
632
633    Conversions from a power-of-2 radix into binary use a simple and fast
634 O(N) bitwise concatenation algorithm.
635
636    Conversions from other radices use one of two algorithms.  Sizes
637 below 'SET_STR_PRECOMPUTE_THRESHOLD' use a basic O(N^2) method.  Groups
638 of n digits are converted to limbs, where n is the biggest power of the
639 base b which will fit in a limb, then those groups are accumulated into
640 the result by multiplying by b^n and adding.  This saves multi-precision
641 operations, as per Knuth section 4.4 part E (*note References::).  Some
642 special case code is provided for decimal, giving the compiler a chance
643 to optimize multiplications by 10.
644
645    Above 'SET_STR_PRECOMPUTE_THRESHOLD' a sub-quadratic algorithm is
646 used.  First groups of n digits are converted into limbs.  Then adjacent
647 limbs are combined into limb pairs with x*b^n+y, where x and y are the
648 limbs.  Adjacent limb pairs are combined into quads similarly with
649 x*b^(2n)+y.  This continues until a single block remains, that being the
650 result.
651
652    The advantage of this method is that the multiplications for each x
653 are big blocks, allowing Karatsuba and higher algorithms to be used.
654 But the cost of calculating the powers b^(n*2^i) must be overcome.
655 'SET_STR_PRECOMPUTE_THRESHOLD' usually ends up quite big, around 5000
656 digits, and on some processors much bigger still.
657
658    'SET_STR_PRECOMPUTE_THRESHOLD' is based on the input digits (and
659 tuned for decimal), though it might be better based on a limb count, so
660 as to be independent of the base.  But that sort of count isn't used by
661 the base case and so would need some sort of initial calculation or
662 estimate.
663
664    The main reason 'SET_STR_PRECOMPUTE_THRESHOLD' is so much bigger than
665 the corresponding 'GET_STR_PRECOMPUTE_THRESHOLD' is that 'mpn_mul_1' is
666 much faster than 'mpn_divrem_1' (often by a factor of 5, or more).
667
668 \1f
669 File: gmp.info,  Node: Other Algorithms,  Next: Assembly Coding,  Prev: Radix Conversion Algorithms,  Up: Algorithms
670
671 15.7 Other Algorithms
672 =====================
673
674 * Menu:
675
676 * Prime Testing Algorithm::
677 * Factorial Algorithm::
678 * Binomial Coefficients Algorithm::
679 * Fibonacci Numbers Algorithm::
680 * Lucas Numbers Algorithm::
681 * Random Number Algorithms::
682
683 \1f
684 File: gmp.info,  Node: Prime Testing Algorithm,  Next: Factorial Algorithm,  Prev: Other Algorithms,  Up: Other Algorithms
685
686 15.7.1 Prime Testing
687 --------------------
688
689 The primality testing in 'mpz_probab_prime_p' (*note Number Theoretic
690 Functions::) first does some trial division by small factors and then
691 uses the Miller-Rabin probabilistic primality testing algorithm, as
692 described in Knuth section 4.5.4 algorithm P (*note References::).
693
694    For an odd input n, and with n = q*2^k+1 where q is odd, this
695 algorithm selects a random base x and tests whether x^q mod n is 1 or
696 -1, or an x^(q*2^j) mod n is 1, for 1<=j<=k.  If so then n is probably
697 prime, if not then n is definitely composite.
698
699    Any prime n will pass the test, but some composites do too.  Such
700 composites are known as strong pseudoprimes to base x.  No n is a strong
701 pseudoprime to more than 1/4 of all bases (see Knuth exercise 22), hence
702 with x chosen at random there's no more than a 1/4 chance a "probable
703 prime" will in fact be composite.
704
705    In fact strong pseudoprimes are quite rare, making the test much more
706 powerful than this analysis would suggest, but 1/4 is all that's proven
707 for an arbitrary n.
708
709 \1f
710 File: gmp.info,  Node: Factorial Algorithm,  Next: Binomial Coefficients Algorithm,  Prev: Prime Testing Algorithm,  Up: Other Algorithms
711
712 15.7.2 Factorial
713 ----------------
714
715 Factorials are calculated by a combination of two algorithms.  An idea
716 is shared among them: to compute the odd part of the factorial; a final
717 step takes account of the power of 2 term, by shifting.
718
719    For small n, the odd factor of n! is computed with the simple
720 observation that it is equal to the product of all positive odd numbers
721 smaller than n times the odd factor of [n/2]!, where [x] is the integer
722 part of x, and so on recursively.  The procedure can be best illustrated
723 with an example,
724
725      23! = (23.21.19.17.15.13.11.9.7.5.3)(11.9.7.5.3)(5.3)2^{19}
726
727    Current code collects all the factors in a single list, with a loop
728 and no recursion, and compute the product, with no special care for
729 repeated chunks.
730
731    When n is larger, computation pass trough prime sieving.  An helper
732 function is used, as suggested by Peter Luschny:
733
734                                  n
735                                -----
736                     n!          | |   L(p,n)
737      msf(n) = -------------- =  | |  p
738                [n/2]!^2.2^k     p=3
739
740    Where p ranges on odd prime numbers.  The exponent k is chosen to
741 obtain an odd integer number: k is the number of 1 bits in the binary
742 representation of [n/2].  The function L(p,n) can be defined as zero
743 when p is composite, and, for any prime p, it is computed with:
744
745                ---
746                 \    n
747      L(p,n) =   /  [---] mod 2   <=  log (n) .
748                ---  p^i                p
749                i>0
750
751    With this helper function, we are able to compute the odd part of n!
752 using the recursion implied by n!=[n/2]!^2*msf(n)*2^k.  The recursion
753 stops using the small-n algorithm on some [n/2^i].
754
755    Both the above algorithms use binary splitting to compute the product
756 of many small factors.  At first as many products as possible are
757 accumulated in a single register, generating a list of factors that fit
758 in a machine word.  This list is then split into halves, and the product
759 is computed recursively.
760
761    Such splitting is more efficient than repeated Nx1 multiplies since
762 it forms big multiplies, allowing Karatsuba and higher algorithms to be
763 used.  And even below the Karatsuba threshold a big block of work can be
764 more efficient for the basecase algorithm.
765
766 \1f
767 File: gmp.info,  Node: Binomial Coefficients Algorithm,  Next: Fibonacci Numbers Algorithm,  Prev: Factorial Algorithm,  Up: Other Algorithms
768
769 15.7.3 Binomial Coefficients
770 ----------------------------
771
772 Binomial coefficients C(n,k) are calculated by first arranging k <= n/2
773 using C(n,k) = C(n,n-k) if necessary, and then evaluating the following
774 product simply from i=2 to i=k.
775
776                            k  (n-k+i)
777      C(n,k) =  (n-k+1) * prod -------
778                           i=2    i
779
780    It's easy to show that each denominator i will divide the product so
781 far, so the exact division algorithm is used (*note Exact Division::).
782
783    The numerators n-k+i and denominators i are first accumulated into as
784 many fit a limb, to save multi-precision operations, though for
785 'mpz_bin_ui' this applies only to the divisors, since n is an 'mpz_t'
786 and n-k+i in general won't fit in a limb at all.
787
788 \1f
789 File: gmp.info,  Node: Fibonacci Numbers Algorithm,  Next: Lucas Numbers Algorithm,  Prev: Binomial Coefficients Algorithm,  Up: Other Algorithms
790
791 15.7.4 Fibonacci Numbers
792 ------------------------
793
794 The Fibonacci functions 'mpz_fib_ui' and 'mpz_fib2_ui' are designed for
795 calculating isolated F[n] or F[n],F[n-1] values efficiently.
796
797    For small n, a table of single limb values in '__gmp_fib_table' is
798 used.  On a 32-bit limb this goes up to F[47], or on a 64-bit limb up to
799 F[93].  For convenience the table starts at F[-1].
800
801    Beyond the table, values are generated with a binary powering
802 algorithm, calculating a pair F[n] and F[n-1] working from high to low
803 across the bits of n.  The formulas used are
804
805      F[2k+1] = 4*F[k]^2 - F[k-1]^2 + 2*(-1)^k
806      F[2k-1] =   F[k]^2 + F[k-1]^2
807
808      F[2k] = F[2k+1] - F[2k-1]
809
810    At each step, k is the high b bits of n.  If the next bit of n is 0
811 then F[2k],F[2k-1] is used, or if it's a 1 then F[2k+1],F[2k] is used,
812 and the process repeated until all bits of n are incorporated.  Notice
813 these formulas require just two squares per bit of n.
814
815    It'd be possible to handle the first few n above the single limb
816 table with simple additions, using the defining Fibonacci recurrence
817 F[k+1]=F[k]+F[k-1], but this is not done since it usually turns out to
818 be faster for only about 10 or 20 values of n, and including a block of
819 code for just those doesn't seem worthwhile.  If they really mattered
820 it'd be better to extend the data table.
821
822    Using a table avoids lots of calculations on small numbers, and makes
823 small n go fast.  A bigger table would make more small n go fast, it's
824 just a question of balancing size against desired speed.  For GMP the
825 code is kept compact, with the emphasis primarily on a good powering
826 algorithm.
827
828    'mpz_fib2_ui' returns both F[n] and F[n-1], but 'mpz_fib_ui' is only
829 interested in F[n].  In this case the last step of the algorithm can
830 become one multiply instead of two squares.  One of the following two
831 formulas is used, according as n is odd or even.
832
833      F[2k]   = F[k]*(F[k]+2F[k-1])
834
835      F[2k+1] = (2F[k]+F[k-1])*(2F[k]-F[k-1]) + 2*(-1)^k
836
837    F[2k+1] here is the same as above, just rearranged to be a multiply.
838 For interest, the 2*(-1)^k term both here and above can be applied just
839 to the low limb of the calculation, without a carry or borrow into
840 further limbs, which saves some code size.  See comments with
841 'mpz_fib_ui' and the internal 'mpn_fib2_ui' for how this is done.
842
843 \1f
844 File: gmp.info,  Node: Lucas Numbers Algorithm,  Next: Random Number Algorithms,  Prev: Fibonacci Numbers Algorithm,  Up: Other Algorithms
845
846 15.7.5 Lucas Numbers
847 --------------------
848
849 'mpz_lucnum2_ui' derives a pair of Lucas numbers from a pair of
850 Fibonacci numbers with the following simple formulas.
851
852      L[k]   =   F[k] + 2*F[k-1]
853      L[k-1] = 2*F[k] -   F[k-1]
854
855    'mpz_lucnum_ui' is only interested in L[n], and some work can be
856 saved.  Trailing zero bits on n can be handled with a single square
857 each.
858
859      L[2k] = L[k]^2 - 2*(-1)^k
860
861    And the lowest 1 bit can be handled with one multiply of a pair of
862 Fibonacci numbers, similar to what 'mpz_fib_ui' does.
863
864      L[2k+1] = 5*F[k-1]*(2*F[k]+F[k-1]) - 4*(-1)^k
865
866 \1f
867 File: gmp.info,  Node: Random Number Algorithms,  Prev: Lucas Numbers Algorithm,  Up: Other Algorithms
868
869 15.7.6 Random Numbers
870 ---------------------
871
872 For the 'urandomb' functions, random numbers are generated simply by
873 concatenating bits produced by the generator.  As long as the generator
874 has good randomness properties this will produce well-distributed N bit
875 numbers.
876
877    For the 'urandomm' functions, random numbers in a range 0<=R<N are
878 generated by taking values R of ceil(log2(N)) bits each until one
879 satisfies R<N. This will normally require only one or two attempts, but
880 the attempts are limited in case the generator is somehow degenerate and
881 produces only 1 bits or similar.
882
883    The Mersenne Twister generator is by Matsumoto and Nishimura (*note
884 References::).  It has a non-repeating period of 2^19937-1, which is a
885 Mersenne prime, hence the name of the generator.  The state is 624 words
886 of 32-bits each, which is iterated with one XOR and shift for each
887 32-bit word generated, making the algorithm very fast.  Randomness
888 properties are also very good and this is the default algorithm used by
889 GMP.
890
891    Linear congruential generators are described in many text books, for
892 instance Knuth volume 2 (*note References::).  With a modulus M and
893 parameters A and C, an integer state S is iterated by the formula S <-
894 A*S+C mod M. At each step the new state is a linear function of the
895 previous, mod M, hence the name of the generator.
896
897    In GMP only moduli of the form 2^N are supported, and the current
898 implementation is not as well optimized as it could be.  Overheads are
899 significant when N is small, and when N is large clearly the multiply at
900 each step will become slow.  This is not a big concern, since the
901 Mersenne Twister generator is better in every respect and is therefore
902 recommended for all normal applications.
903
904    For both generators the current state can be deduced by observing
905 enough output and applying some linear algebra (over GF(2) in the case
906 of the Mersenne Twister).  This generally means raw output is unsuitable
907 for cryptographic applications without further hashing or the like.
908
909 \1f
910 File: gmp.info,  Node: Assembly Coding,  Prev: Other Algorithms,  Up: Algorithms
911
912 15.8 Assembly Coding
913 ====================
914
915 The assembly subroutines in GMP are the most significant source of speed
916 at small to moderate sizes.  At larger sizes algorithm selection becomes
917 more important, but of course speedups in low level routines will still
918 speed up everything proportionally.
919
920    Carry handling and widening multiplies that are important for GMP
921 can't be easily expressed in C.  GCC 'asm' blocks help a lot and are
922 provided in 'longlong.h', but hand coding low level routines invariably
923 offers a speedup over generic C by a factor of anything from 2 to 10.
924
925 * Menu:
926
927 * Assembly Code Organisation::
928 * Assembly Basics::
929 * Assembly Carry Propagation::
930 * Assembly Cache Handling::
931 * Assembly Functional Units::
932 * Assembly Floating Point::
933 * Assembly SIMD Instructions::
934 * Assembly Software Pipelining::
935 * Assembly Loop Unrolling::
936 * Assembly Writing Guide::
937
938 \1f
939 File: gmp.info,  Node: Assembly Code Organisation,  Next: Assembly Basics,  Prev: Assembly Coding,  Up: Assembly Coding
940
941 15.8.1 Code Organisation
942 ------------------------
943
944 The various 'mpn' subdirectories contain machine-dependent code, written
945 in C or assembly.  The 'mpn/generic' subdirectory contains default code,
946 used when there's no machine-specific version of a particular file.
947
948    Each 'mpn' subdirectory is for an ISA family.  Generally 32-bit and
949 64-bit variants in a family cannot share code and have separate
950 directories.  Within a family further subdirectories may exist for CPU
951 variants.
952
953    In each directory a 'nails' subdirectory may exist, holding code with
954 nails support for that CPU variant.  A 'NAILS_SUPPORT' directive in each
955 file indicates the nails values the code handles.  Nails code only
956 exists where it's faster, or promises to be faster, than plain code.
957 There's no effort put into nails if they're not going to enhance a given
958 CPU.
959
960 \1f
961 File: gmp.info,  Node: Assembly Basics,  Next: Assembly Carry Propagation,  Prev: Assembly Code Organisation,  Up: Assembly Coding
962
963 15.8.2 Assembly Basics
964 ----------------------
965
966 'mpn_addmul_1' and 'mpn_submul_1' are the most important routines for
967 overall GMP performance.  All multiplications and divisions come down to
968 repeated calls to these.  'mpn_add_n', 'mpn_sub_n', 'mpn_lshift' and
969 'mpn_rshift' are next most important.
970
971    On some CPUs assembly versions of the internal functions
972 'mpn_mul_basecase' and 'mpn_sqr_basecase' give significant speedups,
973 mainly through avoiding function call overheads.  They can also
974 potentially make better use of a wide superscalar processor, as can
975 bigger primitives like 'mpn_addmul_2' or 'mpn_addmul_4'.
976
977    The restrictions on overlaps between sources and destinations (*note
978 Low-level Functions::) are designed to facilitate a variety of
979 implementations.  For example, knowing 'mpn_add_n' won't have partly
980 overlapping sources and destination means reading can be done far ahead
981 of writing on superscalar processors, and loops can be vectorized on a
982 vector processor, depending on the carry handling.
983
984 \1f
985 File: gmp.info,  Node: Assembly Carry Propagation,  Next: Assembly Cache Handling,  Prev: Assembly Basics,  Up: Assembly Coding
986
987 15.8.3 Carry Propagation
988 ------------------------
989
990 The problem that presents most challenges in GMP is propagating carries
991 from one limb to the next.  In functions like 'mpn_addmul_1' and
992 'mpn_add_n', carries are the only dependencies between limb operations.
993
994    On processors with carry flags, a straightforward CISC style 'adc' is
995 generally best.  AMD K6 'mpn_addmul_1' however is an example of an
996 unusual set of circumstances where a branch works out better.
997
998    On RISC processors generally an add and compare for overflow is used.
999 This sort of thing can be seen in 'mpn/generic/aors_n.c'.  Some carry
1000 propagation schemes require 4 instructions, meaning at least 4 cycles
1001 per limb, but other schemes may use just 1 or 2.  On wide superscalar
1002 processors performance may be completely determined by the number of
1003 dependent instructions between carry-in and carry-out for each limb.
1004
1005    On vector processors good use can be made of the fact that a carry
1006 bit only very rarely propagates more than one limb.  When adding a
1007 single bit to a limb, there's only a carry out if that limb was
1008 '0xFF...FF' which on random data will be only 1 in 2^mp_bits_per_limb.
1009 'mpn/cray/add_n.c' is an example of this, it adds all limbs in parallel,
1010 adds one set of carry bits in parallel and then only rarely needs to
1011 fall through to a loop propagating further carries.
1012
1013    On the x86s, GCC (as of version 2.95.2) doesn't generate particularly
1014 good code for the RISC style idioms that are necessary to handle carry
1015 bits in C.  Often conditional jumps are generated where 'adc' or 'sbb'
1016 forms would be better.  And so unfortunately almost any loop involving
1017 carry bits needs to be coded in assembly for best results.
1018
1019 \1f
1020 File: gmp.info,  Node: Assembly Cache Handling,  Next: Assembly Functional Units,  Prev: Assembly Carry Propagation,  Up: Assembly Coding
1021
1022 15.8.4 Cache Handling
1023 ---------------------
1024
1025 GMP aims to perform well both on operands that fit entirely in L1 cache
1026 and those which don't.
1027
1028    Basic routines like 'mpn_add_n' or 'mpn_lshift' are often used on
1029 large operands, so L2 and main memory performance is important for them.
1030 'mpn_mul_1' and 'mpn_addmul_1' are mostly used for multiply and square
1031 basecases, so L1 performance matters most for them, unless assembly
1032 versions of 'mpn_mul_basecase' and 'mpn_sqr_basecase' exist, in which
1033 case the remaining uses are mostly for larger operands.
1034
1035    For L2 or main memory operands, memory access times will almost
1036 certainly be more than the calculation time.  The aim therefore is to
1037 maximize memory throughput, by starting a load of the next cache line
1038 while processing the contents of the previous one.  Clearly this is only
1039 possible if the chip has a lock-up free cache or some sort of prefetch
1040 instruction.  Most current chips have both these features.
1041
1042    Prefetching sources combines well with loop unrolling, since a
1043 prefetch can be initiated once per unrolled loop (or more than once if
1044 the loop covers more than one cache line).
1045
1046    On CPUs without write-allocate caches, prefetching destinations will
1047 ensure individual stores don't go further down the cache hierarchy,
1048 limiting bandwidth.  Of course for calculations which are slow anyway,
1049 like 'mpn_divrem_1', write-throughs might be fine.
1050
1051    The distance ahead to prefetch will be determined by memory latency
1052 versus throughput.  The aim of course is to have data arriving
1053 continuously, at peak throughput.  Some CPUs have limits on the number
1054 of fetches or prefetches in progress.
1055
1056    If a special prefetch instruction doesn't exist then a plain load can
1057 be used, but in that case care must be taken not to attempt to read past
1058 the end of an operand, since that might produce a segmentation
1059 violation.
1060
1061    Some CPUs or systems have hardware that detects sequential memory
1062 accesses and initiates suitable cache movements automatically, making
1063 life easy.
1064
1065 \1f
1066 File: gmp.info,  Node: Assembly Functional Units,  Next: Assembly Floating Point,  Prev: Assembly Cache Handling,  Up: Assembly Coding
1067
1068 15.8.5 Functional Units
1069 -----------------------
1070
1071 When choosing an approach for an assembly loop, consideration is given
1072 to what operations can execute simultaneously and what throughput can
1073 thereby be achieved.  In some cases an algorithm can be tweaked to
1074 accommodate available resources.
1075
1076    Loop control will generally require a counter and pointer updates,
1077 costing as much as 5 instructions, plus any delays a branch introduces.
1078 CPU addressing modes might reduce pointer updates, perhaps by allowing
1079 just one updating pointer and others expressed as offsets from it, or on
1080 CISC chips with all addressing done with the loop counter as a scaled
1081 index.
1082
1083    The final loop control cost can be amortised by processing several
1084 limbs in each iteration (*note Assembly Loop Unrolling::).  This at
1085 least ensures loop control isn't a big fraction the work done.
1086
1087    Memory throughput is always a limit.  If perhaps only one load or one
1088 store can be done per cycle then 3 cycles/limb will the top speed for
1089 "binary" operations like 'mpn_add_n', and any code achieving that is
1090 optimal.
1091
1092    Integer resources can be freed up by having the loop counter in a
1093 float register, or by pressing the float units into use for some
1094 multiplying, perhaps doing every second limb on the float side (*note
1095 Assembly Floating Point::).
1096
1097    Float resources can be freed up by doing carry propagation on the
1098 integer side, or even by doing integer to float conversions in integers
1099 using bit twiddling.
1100
1101 \1f
1102 File: gmp.info,  Node: Assembly Floating Point,  Next: Assembly SIMD Instructions,  Prev: Assembly Functional Units,  Up: Assembly Coding
1103
1104 15.8.6 Floating Point
1105 ---------------------
1106
1107 Floating point arithmetic is used in GMP for multiplications on CPUs
1108 with poor integer multipliers.  It's mostly useful for 'mpn_mul_1',
1109 'mpn_addmul_1' and 'mpn_submul_1' on 64-bit machines, and
1110 'mpn_mul_basecase' on both 32-bit and 64-bit machines.
1111
1112    With IEEE 53-bit double precision floats, integer multiplications
1113 producing up to 53 bits will give exact results.  Breaking a 64x64
1114 multiplication into eight 16x32->48 bit pieces is convenient.  With some
1115 care though six 21x32->53 bit products can be used, if one of the lower
1116 two 21-bit pieces also uses the sign bit.
1117
1118    For the 'mpn_mul_1' family of functions on a 64-bit machine, the
1119 invariant single limb is split at the start, into 3 or 4 pieces.  Inside
1120 the loop, the bignum operand is split into 32-bit pieces.  Fast
1121 conversion of these unsigned 32-bit pieces to floating point is highly
1122 machine-dependent.  In some cases, reading the data into the integer
1123 unit, zero-extending to 64-bits, then transferring to the floating point
1124 unit back via memory is the only option.
1125
1126    Converting partial products back to 64-bit limbs is usually best done
1127 as a signed conversion.  Since all values are smaller than 2^53, signed
1128 and unsigned are the same, but most processors lack unsigned
1129 conversions.
1130
1131
1132
1133    Here is a diagram showing 16x32 bit products for an 'mpn_mul_1' or
1134 'mpn_addmul_1' with a 64-bit limb.  The single limb operand V is split
1135 into four 16-bit parts.  The multi-limb operand U is split in the loop
1136 into two 32-bit parts.
1137
1138                      +---+---+---+---+
1139                      |v48|v32|v16|v00|    V operand
1140                      +---+---+---+---+
1141
1142                      +-------+---+---+
1143                  x   |  u32  |  u00  |    U operand (one limb)
1144                      +---------------+
1145
1146      ---------------------------------
1147
1148                          +-----------+
1149                          | u00 x v00 |    p00    48-bit products
1150                          +-----------+
1151                      +-----------+
1152                      | u00 x v16 |        p16
1153                      +-----------+
1154                  +-----------+
1155                  | u00 x v32 |            p32
1156                  +-----------+
1157              +-----------+
1158              | u00 x v48 |                p48
1159              +-----------+
1160                  +-----------+
1161                  | u32 x v00 |            r32
1162                  +-----------+
1163              +-----------+
1164              | u32 x v16 |                r48
1165              +-----------+
1166          +-----------+
1167          | u32 x v32 |                    r64
1168          +-----------+
1169      +-----------+
1170      | u32 x v48 |                        r80
1171      +-----------+
1172
1173    p32 and r32 can be summed using floating-point addition, and likewise
1174 p48 and r48.  p00 and p16 can be summed with r64 and r80 from the
1175 previous iteration.
1176
1177    For each loop then, four 49-bit quantities are transferred to the
1178 integer unit, aligned as follows,
1179
1180      |-----64bits----|-----64bits----|
1181                         +------------+
1182                         | p00 + r64' |    i00
1183                         +------------+
1184                     +------------+
1185                     | p16 + r80' |        i16
1186                     +------------+
1187                 +------------+
1188                 | p32 + r32  |            i32
1189                 +------------+
1190             +------------+
1191             | p48 + r48  |                i48
1192             +------------+
1193
1194    The challenge then is to sum these efficiently and add in a carry
1195 limb, generating a low 64-bit result limb and a high 33-bit carry limb
1196 (i48 extends 33 bits into the high half).
1197
1198 \1f
1199 File: gmp.info,  Node: Assembly SIMD Instructions,  Next: Assembly Software Pipelining,  Prev: Assembly Floating Point,  Up: Assembly Coding
1200
1201 15.8.7 SIMD Instructions
1202 ------------------------
1203
1204 The single-instruction multiple-data support in current microprocessors
1205 is aimed at signal processing algorithms where each data point can be
1206 treated more or less independently.  There's generally not much support
1207 for propagating the sort of carries that arise in GMP.
1208
1209    SIMD multiplications of say four 16x16 bit multiplies only do as much
1210 work as one 32x32 from GMP's point of view, and need some shifts and
1211 adds besides.  But of course if say the SIMD form is fully pipelined and
1212 uses less instruction decoding then it may still be worthwhile.
1213
1214    On the x86 chips, MMX has so far found a use in 'mpn_rshift' and
1215 'mpn_lshift', and is used in a special case for 16-bit multipliers in
1216 the P55 'mpn_mul_1'.  SSE2 is used for Pentium 4 'mpn_mul_1',
1217 'mpn_addmul_1', and 'mpn_submul_1'.
1218
1219 \1f
1220 File: gmp.info,  Node: Assembly Software Pipelining,  Next: Assembly Loop Unrolling,  Prev: Assembly SIMD Instructions,  Up: Assembly Coding
1221
1222 15.8.8 Software Pipelining
1223 --------------------------
1224
1225 Software pipelining consists of scheduling instructions around the
1226 branch point in a loop.  For example a loop might issue a load not for
1227 use in the present iteration but the next, thereby allowing extra cycles
1228 for the data to arrive from memory.
1229
1230    Naturally this is wanted only when doing things like loads or
1231 multiplies that take several cycles to complete, and only where a CPU
1232 has multiple functional units so that other work can be done in the
1233 meantime.
1234
1235    A pipeline with several stages will have a data value in progress at
1236 each stage and each loop iteration moves them along one stage.  This is
1237 like juggling.
1238
1239    If the latency of some instruction is greater than the loop time then
1240 it will be necessary to unroll, so one register has a result ready to
1241 use while another (or multiple others) are still in progress.  (*note
1242 Assembly Loop Unrolling::).
1243
1244 \1f
1245 File: gmp.info,  Node: Assembly Loop Unrolling,  Next: Assembly Writing Guide,  Prev: Assembly Software Pipelining,  Up: Assembly Coding
1246
1247 15.8.9 Loop Unrolling
1248 ---------------------
1249
1250 Loop unrolling consists of replicating code so that several limbs are
1251 processed in each loop.  At a minimum this reduces loop overheads by a
1252 corresponding factor, but it can also allow better register usage, for
1253 example alternately using one register combination and then another.
1254 Judicious use of 'm4' macros can help avoid lots of duplication in the
1255 source code.
1256
1257    Any amount of unrolling can be handled with a loop counter that's
1258 decremented by N each time, stopping when the remaining count is less
1259 than the further N the loop will process.  Or by subtracting N at the
1260 start, the termination condition becomes when the counter C is less than
1261 0 (and the count of remaining limbs is C+N).
1262
1263    Alternately for a power of 2 unroll the loop count and remainder can
1264 be established with a shift and mask.  This is convenient if also making
1265 a computed jump into the middle of a large loop.
1266
1267    The limbs not a multiple of the unrolling can be handled in various
1268 ways, for example
1269
1270    * A simple loop at the end (or the start) to process the excess.
1271      Care will be wanted that it isn't too much slower than the unrolled
1272      part.
1273
1274    * A set of binary tests, for example after an 8-limb unrolling, test
1275      for 4 more limbs to process, then a further 2 more or not, and
1276      finally 1 more or not.  This will probably take more code space
1277      than a simple loop.
1278
1279    * A 'switch' statement, providing separate code for each possible
1280      excess, for example an 8-limb unrolling would have separate code
1281      for 0 remaining, 1 remaining, etc, up to 7 remaining.  This might
1282      take a lot of code, but may be the best way to optimize all cases
1283      in combination with a deep pipelined loop.
1284
1285    * A computed jump into the middle of the loop, thus making the first
1286      iteration handle the excess.  This should make times smoothly
1287      increase with size, which is attractive, but setups for the jump
1288      and adjustments for pointers can be tricky and could become quite
1289      difficult in combination with deep pipelining.
1290
1291 \1f
1292 File: gmp.info,  Node: Assembly Writing Guide,  Prev: Assembly Loop Unrolling,  Up: Assembly Coding
1293
1294 15.8.10 Writing Guide
1295 ---------------------
1296
1297 This is a guide to writing software pipelined loops for processing limb
1298 vectors in assembly.
1299
1300    First determine the algorithm and which instructions are needed.
1301 Code it without unrolling or scheduling, to make sure it works.  On a
1302 3-operand CPU try to write each new value to a new register, this will
1303 greatly simplify later steps.
1304
1305    Then note for each instruction the functional unit and/or issue port
1306 requirements.  If an instruction can use either of two units, like U0 or
1307 U1 then make a category "U0/U1".  Count the total using each unit (or
1308 combined unit), and count all instructions.
1309
1310    Figure out from those counts the best possible loop time.  The goal
1311 will be to find a perfect schedule where instruction latencies are
1312 completely hidden.  The total instruction count might be the limiting
1313 factor, or perhaps a particular functional unit.  It might be possible
1314 to tweak the instructions to help the limiting factor.
1315
1316    Suppose the loop time is N, then make N issue buckets, with the final
1317 loop branch at the end of the last.  Now fill the buckets with dummy
1318 instructions using the functional units desired.  Run this to make sure
1319 the intended speed is reached.
1320
1321    Now replace the dummy instructions with the real instructions from
1322 the slow but correct loop you started with.  The first will typically be
1323 a load instruction.  Then the instruction using that value is placed in
1324 a bucket an appropriate distance down.  Run the loop again, to check it
1325 still runs at target speed.
1326
1327    Keep placing instructions, frequently measuring the loop.  After a
1328 few you will need to wrap around from the last bucket back to the top of
1329 the loop.  If you used the new-register for new-value strategy above
1330 then there will be no register conflicts.  If not then take care not to
1331 clobber something already in use.  Changing registers at this time is
1332 very error prone.
1333
1334    The loop will overlap two or more of the original loop iterations,
1335 and the computation of one vector element result will be started in one
1336 iteration of the new loop, and completed one or several iterations
1337 later.
1338
1339    The final step is to create feed-in and wind-down code for the loop.
1340 A good way to do this is to make a copy (or copies) of the loop at the
1341 start and delete those instructions which don't have valid antecedents,
1342 and at the end replicate and delete those whose results are unwanted
1343 (including any further loads).
1344
1345    The loop will have a minimum number of limbs loaded and processed, so
1346 the feed-in code must test if the request size is smaller and skip
1347 either to a suitable part of the wind-down or to special code for small
1348 sizes.
1349
1350 \1f
1351 File: gmp.info,  Node: Internals,  Next: Contributors,  Prev: Algorithms,  Up: Top
1352
1353 16 Internals
1354 ************
1355
1356 *This chapter is provided only for informational purposes and the
1357 various internals described here may change in future GMP releases.
1358 Applications expecting to be compatible with future releases should use
1359 only the documented interfaces described in previous chapters.*
1360
1361 * Menu:
1362
1363 * Integer Internals::
1364 * Rational Internals::
1365 * Float Internals::
1366 * Raw Output Internals::
1367 * C++ Interface Internals::
1368
1369 \1f
1370 File: gmp.info,  Node: Integer Internals,  Next: Rational Internals,  Prev: Internals,  Up: Internals
1371
1372 16.1 Integer Internals
1373 ======================
1374
1375 'mpz_t' variables represent integers using sign and magnitude, in space
1376 dynamically allocated and reallocated.  The fields are as follows.
1377
1378 '_mp_size'
1379      The number of limbs, or the negative of that when representing a
1380      negative integer.  Zero is represented by '_mp_size' set to zero,
1381      in which case the '_mp_d' data is undefined.
1382
1383 '_mp_d'
1384      A pointer to an array of limbs which is the magnitude.  These are
1385      stored "little endian" as per the 'mpn' functions, so '_mp_d[0]' is
1386      the least significant limb and '_mp_d[ABS(_mp_size)-1]' is the most
1387      significant.  Whenever '_mp_size' is non-zero, the most significant
1388      limb is non-zero.
1389
1390      Currently there's always at least one readable limb, so for
1391      instance 'mpz_get_ui' can fetch '_mp_d[0]' unconditionally (though
1392      its value is undefined if '_mp_size' is zero).
1393
1394 '_mp_alloc'
1395      '_mp_alloc' is the number of limbs currently allocated at '_mp_d',
1396      and normally '_mp_alloc >= ABS(_mp_size)'.  When an 'mpz' routine
1397      is about to (or might be about to) increase '_mp_size', it checks
1398      '_mp_alloc' to see whether there's enough space, and reallocates if
1399      not.  'MPZ_REALLOC' is generally used for this.
1400
1401      'mpz_t' variables initialised with the 'mpz_roinit_n' function or
1402      the 'MPZ_ROINIT_N' macro have '_mp_alloc = 0' but can have a
1403      non-zero '_mp_size'.  They can only be used as read-only constants.
1404      See *note Integer Special Functions:: for details.
1405
1406    The various bitwise logical functions like 'mpz_and' behave as if
1407 negative values were twos complement.  But sign and magnitude is always
1408 used internally, and necessary adjustments are made during the
1409 calculations.  Sometimes this isn't pretty, but sign and magnitude are
1410 best for other routines.
1411
1412    Some internal temporary variables are setup with 'MPZ_TMP_INIT' and
1413 these have '_mp_d' space obtained from 'TMP_ALLOC' rather than the
1414 memory allocation functions.  Care is taken to ensure that these are big
1415 enough that no reallocation is necessary (since it would have
1416 unpredictable consequences).
1417
1418    '_mp_size' and '_mp_alloc' are 'int', although 'mp_size_t' is usually
1419 a 'long'.  This is done to make the fields just 32 bits on some 64 bits
1420 systems, thereby saving a few bytes of data space but still providing
1421 plenty of range.
1422
1423 \1f
1424 File: gmp.info,  Node: Rational Internals,  Next: Float Internals,  Prev: Integer Internals,  Up: Internals
1425
1426 16.2 Rational Internals
1427 =======================
1428
1429 'mpq_t' variables represent rationals using an 'mpz_t' numerator and
1430 denominator (*note Integer Internals::).
1431
1432    The canonical form adopted is denominator positive (and non-zero), no
1433 common factors between numerator and denominator, and zero uniquely
1434 represented as 0/1.
1435
1436    It's believed that casting out common factors at each stage of a
1437 calculation is best in general.  A GCD is an O(N^2) operation so it's
1438 better to do a few small ones immediately than to delay and have to do a
1439 big one later.  Knowing the numerator and denominator have no common
1440 factors can be used for example in 'mpq_mul' to make only two cross GCDs
1441 necessary, not four.
1442
1443    This general approach to common factors is badly sub-optimal in the
1444 presence of simple factorizations or little prospect for cancellation,
1445 but GMP has no way to know when this will occur.  As per *note
1446 Efficiency::, that's left to applications.  The 'mpq_t' framework might
1447 still suit, with 'mpq_numref' and 'mpq_denref' for direct access to the
1448 numerator and denominator, or of course 'mpz_t' variables can be used
1449 directly.
1450
1451 \1f
1452 File: gmp.info,  Node: Float Internals,  Next: Raw Output Internals,  Prev: Rational Internals,  Up: Internals
1453
1454 16.3 Float Internals
1455 ====================
1456
1457 Efficient calculation is the primary aim of GMP floats and the use of
1458 whole limbs and simple rounding facilitates this.
1459
1460    'mpf_t' floats have a variable precision mantissa and a single
1461 machine word signed exponent.  The mantissa is represented using sign
1462 and magnitude.
1463
1464         most                   least
1465      significant            significant
1466         limb                   limb
1467
1468                                  _mp_d
1469       |---- _mp_exp --->           |
1470        _____ _____ _____ _____ _____
1471       |_____|_____|_____|_____|_____|
1472                         . <------------ radix point
1473
1474        <-------- _mp_size --------->
1475
1476
1477 The fields are as follows.
1478
1479 '_mp_size'
1480      The number of limbs currently in use, or the negative of that when
1481      representing a negative value.  Zero is represented by '_mp_size'
1482      and '_mp_exp' both set to zero, and in that case the '_mp_d' data
1483      is unused.  (In the future '_mp_exp' might be undefined when
1484      representing zero.)
1485
1486 '_mp_prec'
1487      The precision of the mantissa, in limbs.  In any calculation the
1488      aim is to produce '_mp_prec' limbs of result (the most significant
1489      being non-zero).
1490
1491 '_mp_d'
1492      A pointer to the array of limbs which is the absolute value of the
1493      mantissa.  These are stored "little endian" as per the 'mpn'
1494      functions, so '_mp_d[0]' is the least significant limb and
1495      '_mp_d[ABS(_mp_size)-1]' the most significant.
1496
1497      The most significant limb is always non-zero, but there are no
1498      other restrictions on its value, in particular the highest 1 bit
1499      can be anywhere within the limb.
1500
1501      '_mp_prec+1' limbs are allocated to '_mp_d', the extra limb being
1502      for convenience (see below).  There are no reallocations during a
1503      calculation, only in a change of precision with 'mpf_set_prec'.
1504
1505 '_mp_exp'
1506      The exponent, in limbs, determining the location of the implied
1507      radix point.  Zero means the radix point is just above the most
1508      significant limb.  Positive values mean a radix point offset
1509      towards the lower limbs and hence a value >= 1, as for example in
1510      the diagram above.  Negative exponents mean a radix point further
1511      above the highest limb.
1512
1513      Naturally the exponent can be any value, it doesn't have to fall
1514      within the limbs as the diagram shows, it can be a long way above
1515      or a long way below.  Limbs other than those included in the
1516      '{_mp_d,_mp_size}' data are treated as zero.
1517
1518    The '_mp_size' and '_mp_prec' fields are 'int', although the
1519 'mp_size_t' type is usually a 'long'.  The '_mp_exp' field is usually
1520 'long'.  This is done to make some fields just 32 bits on some 64 bits
1521 systems, thereby saving a few bytes of data space but still providing
1522 plenty of precision and a very large range.
1523
1524
1525 The following various points should be noted.
1526
1527 Low Zeros
1528      The least significant limbs '_mp_d[0]' etc can be zero, though such
1529      low zeros can always be ignored.  Routines likely to produce low
1530      zeros check and avoid them to save time in subsequent calculations,
1531      but for most routines they're quite unlikely and aren't checked.
1532
1533 Mantissa Size Range
1534      The '_mp_size' count of limbs in use can be less than '_mp_prec' if
1535      the value can be represented in less.  This means low precision
1536      values or small integers stored in a high precision 'mpf_t' can
1537      still be operated on efficiently.
1538
1539      '_mp_size' can also be greater than '_mp_prec'.  Firstly a value is
1540      allowed to use all of the '_mp_prec+1' limbs available at '_mp_d',
1541      and secondly when 'mpf_set_prec_raw' lowers '_mp_prec' it leaves
1542      '_mp_size' unchanged and so the size can be arbitrarily bigger than
1543      '_mp_prec'.
1544
1545 Rounding
1546      All rounding is done on limb boundaries.  Calculating '_mp_prec'
1547      limbs with the high non-zero will ensure the application requested
1548      minimum precision is obtained.
1549
1550      The use of simple "trunc" rounding towards zero is efficient, since
1551      there's no need to examine extra limbs and increment or decrement.
1552
1553 Bit Shifts
1554      Since the exponent is in limbs, there are no bit shifts in basic
1555      operations like 'mpf_add' and 'mpf_mul'.  When differing exponents
1556      are encountered all that's needed is to adjust pointers to line up
1557      the relevant limbs.
1558
1559      Of course 'mpf_mul_2exp' and 'mpf_div_2exp' will require bit
1560      shifts, but the choice is between an exponent in limbs which
1561      requires shifts there, or one in bits which requires them almost
1562      everywhere else.
1563
1564 Use of '_mp_prec+1' Limbs
1565      The extra limb on '_mp_d' ('_mp_prec+1' rather than just
1566      '_mp_prec') helps when an 'mpf' routine might get a carry from its
1567      operation.  'mpf_add' for instance will do an 'mpn_add' of
1568      '_mp_prec' limbs.  If there's no carry then that's the result, but
1569      if there is a carry then it's stored in the extra limb of space and
1570      '_mp_size' becomes '_mp_prec+1'.
1571
1572      Whenever '_mp_prec+1' limbs are held in a variable, the low limb is
1573      not needed for the intended precision, only the '_mp_prec' high
1574      limbs.  But zeroing it out or moving the rest down is unnecessary.
1575      Subsequent routines reading the value will simply take the high
1576      limbs they need, and this will be '_mp_prec' if their target has
1577      that same precision.  This is no more than a pointer adjustment,
1578      and must be checked anyway since the destination precision can be
1579      different from the sources.
1580
1581      Copy functions like 'mpf_set' will retain a full '_mp_prec+1' limbs
1582      if available.  This ensures that a variable which has '_mp_size'
1583      equal to '_mp_prec+1' will get its full exact value copied.
1584      Strictly speaking this is unnecessary since only '_mp_prec' limbs
1585      are needed for the application's requested precision, but it's
1586      considered that an 'mpf_set' from one variable into another of the
1587      same precision ought to produce an exact copy.
1588
1589 Application Precisions
1590      '__GMPF_BITS_TO_PREC' converts an application requested precision
1591      to an '_mp_prec'.  The value in bits is rounded up to a whole limb
1592      then an extra limb is added since the most significant limb of
1593      '_mp_d' is only non-zero and therefore might contain only one bit.
1594
1595      '__GMPF_PREC_TO_BITS' does the reverse conversion, and removes the
1596      extra limb from '_mp_prec' before converting to bits.  The net
1597      effect of reading back with 'mpf_get_prec' is simply the precision
1598      rounded up to a multiple of 'mp_bits_per_limb'.
1599
1600      Note that the extra limb added here for the high only being
1601      non-zero is in addition to the extra limb allocated to '_mp_d'.
1602      For example with a 32-bit limb, an application request for 250 bits
1603      will be rounded up to 8 limbs, then an extra added for the high
1604      being only non-zero, giving an '_mp_prec' of 9.  '_mp_d' then gets
1605      10 limbs allocated.  Reading back with 'mpf_get_prec' will take
1606      '_mp_prec' subtract 1 limb and multiply by 32, giving 256 bits.
1607
1608      Strictly speaking, the fact the high limb has at least one bit
1609      means that a float with, say, 3 limbs of 32-bits each will be
1610      holding at least 65 bits, but for the purposes of 'mpf_t' it's
1611      considered simply to be 64 bits, a nice multiple of the limb size.
1612
1613 \1f
1614 File: gmp.info,  Node: Raw Output Internals,  Next: C++ Interface Internals,  Prev: Float Internals,  Up: Internals
1615
1616 16.4 Raw Output Internals
1617 =========================
1618
1619 'mpz_out_raw' uses the following format.
1620
1621      +------+------------------------+
1622      | size |       data bytes       |
1623      +------+------------------------+
1624
1625    The size is 4 bytes written most significant byte first, being the
1626 number of subsequent data bytes, or the twos complement negative of that
1627 when a negative integer is represented.  The data bytes are the absolute
1628 value of the integer, written most significant byte first.
1629
1630    The most significant data byte is always non-zero, so the output is
1631 the same on all systems, irrespective of limb size.
1632
1633    In GMP 1, leading zero bytes were written to pad the data bytes to a
1634 multiple of the limb size.  'mpz_inp_raw' will still accept this, for
1635 compatibility.
1636
1637    The use of "big endian" for both the size and data fields is
1638 deliberate, it makes the data easy to read in a hex dump of a file.
1639 Unfortunately it also means that the limb data must be reversed when
1640 reading or writing, so neither a big endian nor little endian system can
1641 just read and write '_mp_d'.
1642
1643 \1f
1644 File: gmp.info,  Node: C++ Interface Internals,  Prev: Raw Output Internals,  Up: Internals
1645
1646 16.5 C++ Interface Internals
1647 ============================
1648
1649 A system of expression templates is used to ensure something like
1650 'a=b+c' turns into a simple call to 'mpz_add' etc.  For 'mpf_class' the
1651 scheme also ensures the precision of the final destination is used for
1652 any temporaries within a statement like 'f=w*x+y*z'.  These are
1653 important features which a naive implementation cannot provide.
1654
1655    A simplified description of the scheme follows.  The true scheme is
1656 complicated by the fact that expressions have different return types.
1657 For detailed information, refer to the source code.
1658
1659    To perform an operation, say, addition, we first define a "function
1660 object" evaluating it,
1661
1662      struct __gmp_binary_plus
1663      {
1664        static void eval(mpf_t f, const mpf_t g, const mpf_t h)
1665        {
1666          mpf_add(f, g, h);
1667        }
1668      };
1669
1670 And an "additive expression" object,
1671
1672      __gmp_expr<__gmp_binary_expr<mpf_class, mpf_class, __gmp_binary_plus> >
1673      operator+(const mpf_class &f, const mpf_class &g)
1674      {
1675        return __gmp_expr
1676          <__gmp_binary_expr<mpf_class, mpf_class, __gmp_binary_plus> >(f, g);
1677      }
1678
1679    The seemingly redundant '__gmp_expr<__gmp_binary_expr<...>>' is used
1680 to encapsulate any possible kind of expression into a single template
1681 type.  In fact even 'mpf_class' etc are 'typedef' specializations of
1682 '__gmp_expr'.
1683
1684    Next we define assignment of '__gmp_expr' to 'mpf_class'.
1685
1686      template <class T>
1687      mpf_class & mpf_class::operator=(const __gmp_expr<T> &expr)
1688      {
1689        expr.eval(this->get_mpf_t(), this->precision());
1690        return *this;
1691      }
1692
1693      template <class Op>
1694      void __gmp_expr<__gmp_binary_expr<mpf_class, mpf_class, Op> >::eval
1695      (mpf_t f, mp_bitcnt_t precision)
1696      {
1697        Op::eval(f, expr.val1.get_mpf_t(), expr.val2.get_mpf_t());
1698      }
1699
1700    where 'expr.val1' and 'expr.val2' are references to the expression's
1701 operands (here 'expr' is the '__gmp_binary_expr' stored within the
1702 '__gmp_expr').
1703
1704    This way, the expression is actually evaluated only at the time of
1705 assignment, when the required precision (that of 'f') is known.
1706 Furthermore the target 'mpf_t' is now available, thus we can call
1707 'mpf_add' directly with 'f' as the output argument.
1708
1709    Compound expressions are handled by defining operators taking
1710 subexpressions as their arguments, like this:
1711
1712      template <class T, class U>
1713      __gmp_expr
1714      <__gmp_binary_expr<__gmp_expr<T>, __gmp_expr<U>, __gmp_binary_plus> >
1715      operator+(const __gmp_expr<T> &expr1, const __gmp_expr<U> &expr2)
1716      {
1717        return __gmp_expr
1718          <__gmp_binary_expr<__gmp_expr<T>, __gmp_expr<U>, __gmp_binary_plus> >
1719          (expr1, expr2);
1720      }
1721
1722    And the corresponding specializations of '__gmp_expr::eval':
1723
1724      template <class T, class U, class Op>
1725      void __gmp_expr
1726      <__gmp_binary_expr<__gmp_expr<T>, __gmp_expr<U>, Op> >::eval
1727      (mpf_t f, mp_bitcnt_t precision)
1728      {
1729        // declare two temporaries
1730        mpf_class temp1(expr.val1, precision), temp2(expr.val2, precision);
1731        Op::eval(f, temp1.get_mpf_t(), temp2.get_mpf_t());
1732      }
1733
1734    The expression is thus recursively evaluated to any level of
1735 complexity and all subexpressions are evaluated to the precision of 'f'.
1736
1737 \1f
1738 File: gmp.info,  Node: Contributors,  Next: References,  Prev: Internals,  Up: Top
1739
1740 Appendix A Contributors
1741 ***********************
1742
1743 Torbjörn Granlund wrote the original GMP library and is still the main
1744 developer.  Code not explicitly attributed to others, was contributed by
1745 Torbjörn.  Several other individuals and organizations have contributed
1746 GMP. Here is a list in chronological order on first contribution:
1747
1748    Gunnar Sjödin and Hans Riesel helped with mathematical problems in
1749 early versions of the library.
1750
1751    Richard Stallman helped with the interface design and revised the
1752 first version of this manual.
1753
1754    Brian Beuning and Doug Lea helped with testing of early versions of
1755 the library and made creative suggestions.
1756
1757    John Amanatides of York University in Canada contributed the function
1758 'mpz_probab_prime_p'.
1759
1760    Paul Zimmermann wrote the REDC-based mpz_powm code, the
1761 Schönhage-Strassen FFT multiply code, and the Karatsuba square root
1762 code.  He also improved the Toom3 code for GMP 4.2.  Paul sparked the
1763 development of GMP 2, with his comparisons between bignum packages.  The
1764 ECMNET project Paul is organizing was a driving force behind many of the
1765 optimizations in GMP 3.  Paul also wrote the new GMP 4.3 nth root code
1766 (with Torbjörn).
1767
1768    Ken Weber (Kent State University, Universidade Federal do Rio Grande
1769 do Sul) contributed now defunct versions of 'mpz_gcd', 'mpz_divexact',
1770 'mpn_gcd', and 'mpn_bdivmod', partially supported by CNPq (Brazil) grant
1771 301314194-2.
1772
1773    Per Bothner of Cygnus Support helped to set up GMP to use Cygnus'
1774 configure.  He has also made valuable suggestions and tested numerous
1775 intermediary releases.
1776
1777    Joachim Hollman was involved in the design of the 'mpf' interface,
1778 and in the 'mpz' design revisions for version 2.
1779
1780    Bennet Yee contributed the initial versions of 'mpz_jacobi' and
1781 'mpz_legendre'.
1782
1783    Andreas Schwab contributed the files 'mpn/m68k/lshift.S' and
1784 'mpn/m68k/rshift.S' (now in '.asm' form).
1785
1786    Robert Harley of Inria, France and David Seal of ARM, England,
1787 suggested clever improvements for population count.  Robert also wrote
1788 highly optimized Karatsuba and 3-way Toom multiplication functions for
1789 GMP 3, and contributed the ARM assembly code.
1790
1791    Torsten Ekedahl of the Mathematical department of Stockholm
1792 University provided significant inspiration during several phases of the
1793 GMP development.  His mathematical expertise helped improve several
1794 algorithms.
1795
1796    Linus Nordberg wrote the new configure system based on autoconf and
1797 implemented the new random functions.
1798
1799    Kevin Ryde worked on a large number of things: optimized x86 code, m4
1800 asm macros, parameter tuning, speed measuring, the configure system,
1801 function inlining, divisibility tests, bit scanning, Jacobi symbols,
1802 Fibonacci and Lucas number functions, printf and scanf functions, perl
1803 interface, demo expression parser, the algorithms chapter in the manual,
1804 'gmpasm-mode.el', and various miscellaneous improvements elsewhere.
1805
1806    Kent Boortz made the Mac OS 9 port.
1807
1808    Steve Root helped write the optimized alpha 21264 assembly code.
1809
1810    Gerardo Ballabio wrote the 'gmpxx.h' C++ class interface and the C++
1811 'istream' input routines.
1812
1813    Jason Moxham rewrote 'mpz_fac_ui'.
1814
1815    Pedro Gimeno implemented the Mersenne Twister and made other random
1816 number improvements.
1817
1818    Niels Möller wrote the sub-quadratic GCD, extended GCD and jacobi
1819 code, the quadratic Hensel division code, and (with Torbjörn) the new
1820 divide and conquer division code for GMP 4.3.  Niels also helped
1821 implement the new Toom multiply code for GMP 4.3 and implemented helper
1822 functions to simplify Toom evaluations for GMP 5.0.  He wrote the
1823 original version of mpn_mulmod_bnm1, and he is the main author of the
1824 mini-gmp package used for gmp bootstrapping.
1825
1826    Alberto Zanoni and Marco Bodrato suggested the unbalanced multiply
1827 strategy, and found the optimal strategies for evaluation and
1828 interpolation in Toom multiplication.
1829
1830    Marco Bodrato helped implement the new Toom multiply code for GMP 4.3
1831 and implemented most of the new Toom multiply and squaring code for 5.0.
1832 He is the main author of the current mpn_mulmod_bnm1, mpn_mullo_n, and
1833 mpn_sqrlo.  Marco also wrote the functions mpn_invert and
1834 mpn_invertappr, and improved the speed of integer root extraction.  He
1835 is the author of mini-mpq, an additional layer to mini-gmp; of most of
1836 the combinatorial functions and the BPSW primality testing
1837 implementation, for both the main library and the mini-gmp package.
1838
1839    David Harvey suggested the internal function 'mpn_bdiv_dbm1',
1840 implementing division relevant to Toom multiplication.  He also worked
1841 on fast assembly sequences, in particular on a fast AMD64
1842 'mpn_mul_basecase'.  He wrote the internal middle product functions
1843 'mpn_mulmid_basecase', 'mpn_toom42_mulmid', 'mpn_mulmid_n' and related
1844 helper routines.
1845
1846    Martin Boij wrote 'mpn_perfect_power_p'.
1847
1848    Marc Glisse improved 'gmpxx.h': use fewer temporaries (faster),
1849 specializations of 'numeric_limits' and 'common_type', C++11 features
1850 (move constructors, explicit bool conversion, UDL), make the conversion
1851 from 'mpq_class' to 'mpz_class' explicit, optimize operations where one
1852 argument is a small compile-time constant, replace some heap allocations
1853 by stack allocations.  He also fixed the eofbit handling of C++ streams,
1854 and removed one division from 'mpq/aors.c'.
1855
1856    David S Miller wrote assembly code for SPARC T3 and T4.
1857
1858    Mark Sofroniou cleaned up the types of mul_fft.c, letting it work for
1859 huge operands.
1860
1861    Ulrich Weigand ported GMP to the powerpc64le ABI.
1862
1863    (This list is chronological, not ordered after significance.  If you
1864 have contributed to GMP but are not listed above, please tell
1865 <gmp-devel@gmplib.org> about the omission!)
1866
1867    The development of floating point functions of GNU MP 2, were
1868 supported in part by the ESPRIT-BRA (Basic Research Activities) 6846
1869 project POSSO (POlynomial System SOlving).
1870
1871    The development of GMP 2, 3, and 4.0 was supported in part by the IDA
1872 Center for Computing Sciences.
1873
1874    The development of GMP 4.3, 5.0, and 5.1 was supported in part by the
1875 Swedish Foundation for Strategic Research.
1876
1877    Thanks go to Hans Thorsen for donating an SGI system for the GMP test
1878 system environment.
1879
1880 \1f
1881 File: gmp.info,  Node: References,  Next: GNU Free Documentation License,  Prev: Contributors,  Up: Top
1882
1883 Appendix B References
1884 *********************
1885
1886 B.1 Books
1887 =========
1888
1889    * Jonathan M. Borwein and Peter B. Borwein, "Pi and the AGM: A Study
1890      in Analytic Number Theory and Computational Complexity", Wiley,
1891      1998.
1892
1893    * Richard Crandall and Carl Pomerance, "Prime Numbers: A
1894      Computational Perspective", 2nd edition, Springer-Verlag, 2005.
1895      <https://www.math.dartmouth.edu/~carlp/>
1896
1897    * Henri Cohen, "A Course in Computational Algebraic Number Theory",
1898      Graduate Texts in Mathematics number 138, Springer-Verlag, 1993.
1899      <https://www.math.u-bordeaux.fr/~cohen/>
1900
1901    * Donald E. Knuth, "The Art of Computer Programming", volume 2,
1902      "Seminumerical Algorithms", 3rd edition, Addison-Wesley, 1998.
1903      <https://www-cs-faculty.stanford.edu/~knuth/taocp.html>
1904
1905    * John D. Lipson, "Elements of Algebra and Algebraic Computing", The
1906      Benjamin Cummings Publishing Company Inc, 1981.
1907
1908    * Alfred J. Menezes, Paul C. van Oorschot and Scott A. Vanstone,
1909      "Handbook of Applied Cryptography",
1910      <http://www.cacr.math.uwaterloo.ca/hac/>
1911
1912    * Richard M. Stallman and the GCC Developer Community, "Using the GNU
1913      Compiler Collection", Free Software Foundation, 2008, available
1914      online <https://gcc.gnu.org/onlinedocs/>, and in the GCC package
1915      <https://ftp.gnu.org/gnu/gcc/>
1916
1917 B.2 Papers
1918 ==========
1919
1920    * Yves Bertot, Nicolas Magaud and Paul Zimmermann, "A Proof of GMP
1921      Square Root", Journal of Automated Reasoning, volume 29, 2002, pp.
1922      225-252.  Also available online as INRIA Research Report 4475, June
1923      2002, <https://hal.inria.fr/docs/00/07/21/13/PDF/RR-4475.pdf>
1924
1925    * Christoph Burnikel and Joachim Ziegler, "Fast Recursive Division",
1926      Max-Planck-Institut fuer Informatik Research Report MPI-I-98-1-022,
1927      <https://www.mpi-inf.mpg.de/~ziegler/TechRep.ps.gz>
1928
1929    * Torbjörn Granlund and Peter L. Montgomery, "Division by Invariant
1930      Integers using Multiplication", in Proceedings of the SIGPLAN
1931      PLDI'94 Conference, June 1994.  Also available
1932      <https://gmplib.org/~tege/divcnst-pldi94.pdf>.
1933
1934    * Niels Möller and Torbjörn Granlund, "Improved division by invariant
1935      integers", IEEE Transactions on Computers, 11 June 2010.
1936      <https://gmplib.org/~tege/division-paper.pdf>
1937
1938    * Torbjörn Granlund and Niels Möller, "Division of integers large and
1939      small", to appear.
1940
1941    * Tudor Jebelean, "An algorithm for exact division", Journal of
1942      Symbolic Computation, volume 15, 1993, pp. 169-180.  Research
1943      report version available
1944      <ftp://ftp.risc.uni-linz.ac.at/pub/techreports/1992/92-35.ps.gz>
1945
1946    * Tudor Jebelean, "Exact Division with Karatsuba Complexity -
1947      Extended Abstract", RISC-Linz technical report 96-31,
1948      <ftp://ftp.risc.uni-linz.ac.at/pub/techreports/1996/96-31.ps.gz>
1949
1950    * Tudor Jebelean, "Practical Integer Division with Karatsuba
1951      Complexity", ISSAC 97, pp. 339-341.  Technical report available
1952      <ftp://ftp.risc.uni-linz.ac.at/pub/techreports/1996/96-29.ps.gz>
1953
1954    * Tudor Jebelean, "A Generalization of the Binary GCD Algorithm",
1955      ISSAC 93, pp. 111-116.  Technical report version available
1956      <ftp://ftp.risc.uni-linz.ac.at/pub/techreports/1993/93-01.ps.gz>
1957
1958    * Tudor Jebelean, "A Double-Digit Lehmer-Euclid Algorithm for Finding
1959      the GCD of Long Integers", Journal of Symbolic Computation, volume
1960      19, 1995, pp. 145-157.  Technical report version also available
1961      <ftp://ftp.risc.uni-linz.ac.at/pub/techreports/1992/92-69.ps.gz>
1962
1963    * Werner Krandick and Tudor Jebelean, "Bidirectional Exact Integer
1964      Division", Journal of Symbolic Computation, volume 21, 1996, pp.
1965      441-455.  Early technical report version also available
1966      <ftp://ftp.risc.uni-linz.ac.at/pub/techreports/1994/94-50.ps.gz>
1967
1968    * Makoto Matsumoto and Takuji Nishimura, "Mersenne Twister: A
1969      623-dimensionally equidistributed uniform pseudorandom number
1970      generator", ACM Transactions on Modelling and Computer Simulation,
1971      volume 8, January 1998, pp. 3-30.  Available online
1972      <http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/ARTICLES/mt.pdf>
1973
1974    * R. Moenck and A. Borodin, "Fast Modular Transforms via Division",
1975      Proceedings of the 13th Annual IEEE Symposium on Switching and
1976      Automata Theory, October 1972, pp. 90-96.  Reprinted as "Fast
1977      Modular Transforms", Journal of Computer and System Sciences,
1978      volume 8, number 3, June 1974, pp. 366-386.
1979
1980    * Niels Möller, "On Schönhage's algorithm and subquadratic integer
1981      GCD computation", in Mathematics of Computation, volume 77, January
1982      2008, pp. 589-607,
1983      <https://www.ams.org/journals/mcom/2008-77-261/S0025-5718-07-02017-0/home.html>
1984
1985    * Peter L. Montgomery, "Modular Multiplication Without Trial
1986      Division", in Mathematics of Computation, volume 44, number 170,
1987      April 1985.
1988
1989    * Arnold Schönhage and Volker Strassen, "Schnelle Multiplikation
1990      grosser Zahlen", Computing 7, 1971, pp. 281-292.
1991
1992    * Kenneth Weber, "The accelerated integer GCD algorithm", ACM
1993      Transactions on Mathematical Software, volume 21, number 1, March
1994      1995, pp. 111-122.
1995
1996    * Paul Zimmermann, "Karatsuba Square Root", INRIA Research Report
1997      3805, November 1999,
1998      <https://hal.inria.fr/inria-00072854/PDF/RR-3805.pdf>
1999
2000    * Paul Zimmermann, "A Proof of GMP Fast Division and Square Root
2001      Implementations",
2002      <https://homepages.loria.fr/PZimmermann/papers/proof-div-sqrt.ps.gz>
2003
2004    * Dan Zuras, "On Squaring and Multiplying Large Integers", ARITH-11:
2005      IEEE Symposium on Computer Arithmetic, 1993, pp. 260 to 271.
2006      Reprinted as "More on Multiplying and Squaring Large Integers",
2007      IEEE Transactions on Computers, volume 43, number 8, August 1994,
2008      pp. 899-908.
2009
2010    * Niels Möller, "Efficient computation of the Jacobi symbol",
2011      <https://arxiv.org/abs/1907.07795>
2012
2013 \1f
2014 File: gmp.info,  Node: GNU Free Documentation License,  Next: Concept Index,  Prev: References,  Up: Top
2015
2016 Appendix C GNU Free Documentation License
2017 *****************************************
2018
2019                      Version 1.3, 3 November 2008
2020
2021      Copyright Â© 2000-2002, 2007, 2008 Free Software Foundation, Inc.
2022      <http://fsf.org/>
2023
2024      Everyone is permitted to copy and distribute verbatim copies
2025      of this license document, but changing it is not allowed.
2026
2027   0. PREAMBLE
2028
2029      The purpose of this License is to make a manual, textbook, or other
2030      functional and useful document "free" in the sense of freedom: to
2031      assure everyone the effective freedom to copy and redistribute it,
2032      with or without modifying it, either commercially or
2033      noncommercially.  Secondarily, this License preserves for the
2034      author and publisher a way to get credit for their work, while not
2035      being considered responsible for modifications made by others.
2036
2037      This License is a kind of "copyleft", which means that derivative
2038      works of the document must themselves be free in the same sense.
2039      It complements the GNU General Public License, which is a copyleft
2040      license designed for free software.
2041
2042      We have designed this License in order to use it for manuals for
2043      free software, because free software needs free documentation: a
2044      free program should come with manuals providing the same freedoms
2045      that the software does.  But this License is not limited to
2046      software manuals; it can be used for any textual work, regardless
2047      of subject matter or whether it is published as a printed book.  We
2048      recommend this License principally for works whose purpose is
2049      instruction or reference.
2050
2051   1. APPLICABILITY AND DEFINITIONS
2052
2053      This License applies to any manual or other work, in any medium,
2054      that contains a notice placed by the copyright holder saying it can
2055      be distributed under the terms of this License.  Such a notice
2056      grants a world-wide, royalty-free license, unlimited in duration,
2057      to use that work under the conditions stated herein.  The
2058      "Document", below, refers to any such manual or work.  Any member
2059      of the public is a licensee, and is addressed as "you".  You accept
2060      the license if you copy, modify or distribute the work in a way
2061      requiring permission under copyright law.
2062
2063      A "Modified Version" of the Document means any work containing the
2064      Document or a portion of it, either copied verbatim, or with
2065      modifications and/or translated into another language.
2066
2067      A "Secondary Section" is a named appendix or a front-matter section
2068      of the Document that deals exclusively with the relationship of the
2069      publishers or authors of the Document to the Document's overall
2070      subject (or to related matters) and contains nothing that could
2071      fall directly within that overall subject.  (Thus, if the Document
2072      is in part a textbook of mathematics, a Secondary Section may not
2073      explain any mathematics.)  The relationship could be a matter of
2074      historical connection with the subject or with related matters, or
2075      of legal, commercial, philosophical, ethical or political position
2076      regarding them.
2077
2078      The "Invariant Sections" are certain Secondary Sections whose
2079      titles are designated, as being those of Invariant Sections, in the
2080      notice that says that the Document is released under this License.
2081      If a section does not fit the above definition of Secondary then it
2082      is not allowed to be designated as Invariant.  The Document may
2083      contain zero Invariant Sections.  If the Document does not identify
2084      any Invariant Sections then there are none.
2085
2086      The "Cover Texts" are certain short passages of text that are
2087      listed, as Front-Cover Texts or Back-Cover Texts, in the notice
2088      that says that the Document is released under this License.  A
2089      Front-Cover Text may be at most 5 words, and a Back-Cover Text may
2090      be at most 25 words.
2091
2092      A "Transparent" copy of the Document means a machine-readable copy,
2093      represented in a format whose specification is available to the
2094      general public, that is suitable for revising the document
2095      straightforwardly with generic text editors or (for images composed
2096      of pixels) generic paint programs or (for drawings) some widely
2097      available drawing editor, and that is suitable for input to text
2098      formatters or for automatic translation to a variety of formats
2099      suitable for input to text formatters.  A copy made in an otherwise
2100      Transparent file format whose markup, or absence of markup, has
2101      been arranged to thwart or discourage subsequent modification by
2102      readers is not Transparent.  An image format is not Transparent if
2103      used for any substantial amount of text.  A copy that is not
2104      "Transparent" is called "Opaque".
2105
2106      Examples of suitable formats for Transparent copies include plain
2107      ASCII without markup, Texinfo input format, LaTeX input format,
2108      SGML or XML using a publicly available DTD, and standard-conforming
2109      simple HTML, PostScript or PDF designed for human modification.
2110      Examples of transparent image formats include PNG, XCF and JPG.
2111      Opaque formats include proprietary formats that can be read and
2112      edited only by proprietary word processors, SGML or XML for which
2113      the DTD and/or processing tools are not generally available, and
2114      the machine-generated HTML, PostScript or PDF produced by some word
2115      processors for output purposes only.
2116
2117      The "Title Page" means, for a printed book, the title page itself,
2118      plus such following pages as are needed to hold, legibly, the
2119      material this License requires to appear in the title page.  For
2120      works in formats which do not have any title page as such, "Title
2121      Page" means the text near the most prominent appearance of the
2122      work's title, preceding the beginning of the body of the text.
2123
2124      The "publisher" means any person or entity that distributes copies
2125      of the Document to the public.
2126
2127      A section "Entitled XYZ" means a named subunit of the Document
2128      whose title either is precisely XYZ or contains XYZ in parentheses
2129      following text that translates XYZ in another language.  (Here XYZ
2130      stands for a specific section name mentioned below, such as
2131      "Acknowledgements", "Dedications", "Endorsements", or "History".)
2132      To "Preserve the Title" of such a section when you modify the
2133      Document means that it remains a section "Entitled XYZ" according
2134      to this definition.
2135
2136      The Document may include Warranty Disclaimers next to the notice
2137      which states that this License applies to the Document.  These
2138      Warranty Disclaimers are considered to be included by reference in
2139      this License, but only as regards disclaiming warranties: any other
2140      implication that these Warranty Disclaimers may have is void and
2141      has no effect on the meaning of this License.
2142
2143   2. VERBATIM COPYING
2144
2145      You may copy and distribute the Document in any medium, either
2146      commercially or noncommercially, provided that this License, the
2147      copyright notices, and the license notice saying this License
2148      applies to the Document are reproduced in all copies, and that you
2149      add no other conditions whatsoever to those of this License.  You
2150      may not use technical measures to obstruct or control the reading
2151      or further copying of the copies you make or distribute.  However,
2152      you may accept compensation in exchange for copies.  If you
2153      distribute a large enough number of copies you must also follow the
2154      conditions in section 3.
2155
2156      You may also lend copies, under the same conditions stated above,
2157      and you may publicly display copies.
2158
2159   3. COPYING IN QUANTITY
2160
2161      If you publish printed copies (or copies in media that commonly
2162      have printed covers) of the Document, numbering more than 100, and
2163      the Document's license notice requires Cover Texts, you must
2164      enclose the copies in covers that carry, clearly and legibly, all
2165      these Cover Texts: Front-Cover Texts on the front cover, and
2166      Back-Cover Texts on the back cover.  Both covers must also clearly
2167      and legibly identify you as the publisher of these copies.  The
2168      front cover must present the full title with all words of the title
2169      equally prominent and visible.  You may add other material on the
2170      covers in addition.  Copying with changes limited to the covers, as
2171      long as they preserve the title of the Document and satisfy these
2172      conditions, can be treated as verbatim copying in other respects.
2173
2174      If the required texts for either cover are too voluminous to fit
2175      legibly, you should put the first ones listed (as many as fit
2176      reasonably) on the actual cover, and continue the rest onto
2177      adjacent pages.
2178
2179      If you publish or distribute Opaque copies of the Document
2180      numbering more than 100, you must either include a machine-readable
2181      Transparent copy along with each Opaque copy, or state in or with
2182      each Opaque copy a computer-network location from which the general
2183      network-using public has access to download using public-standard
2184      network protocols a complete Transparent copy of the Document, free
2185      of added material.  If you use the latter option, you must take
2186      reasonably prudent steps, when you begin distribution of Opaque
2187      copies in quantity, to ensure that this Transparent copy will
2188      remain thus accessible at the stated location until at least one
2189      year after the last time you distribute an Opaque copy (directly or
2190      through your agents or retailers) of that edition to the public.
2191
2192      It is requested, but not required, that you contact the authors of
2193      the Document well before redistributing any large number of copies,
2194      to give them a chance to provide you with an updated version of the
2195      Document.
2196
2197   4. MODIFICATIONS
2198
2199      You may copy and distribute a Modified Version of the Document
2200      under the conditions of sections 2 and 3 above, provided that you
2201      release the Modified Version under precisely this License, with the
2202      Modified Version filling the role of the Document, thus licensing
2203      distribution and modification of the Modified Version to whoever
2204      possesses a copy of it.  In addition, you must do these things in
2205      the Modified Version:
2206
2207        A. Use in the Title Page (and on the covers, if any) a title
2208           distinct from that of the Document, and from those of previous
2209           versions (which should, if there were any, be listed in the
2210           History section of the Document).  You may use the same title
2211           as a previous version if the original publisher of that
2212           version gives permission.
2213
2214        B. List on the Title Page, as authors, one or more persons or
2215           entities responsible for authorship of the modifications in
2216           the Modified Version, together with at least five of the
2217           principal authors of the Document (all of its principal
2218           authors, if it has fewer than five), unless they release you
2219           from this requirement.
2220
2221        C. State on the Title page the name of the publisher of the
2222           Modified Version, as the publisher.
2223
2224        D. Preserve all the copyright notices of the Document.
2225
2226        E. Add an appropriate copyright notice for your modifications
2227           adjacent to the other copyright notices.
2228
2229        F. Include, immediately after the copyright notices, a license
2230           notice giving the public permission to use the Modified
2231           Version under the terms of this License, in the form shown in
2232           the Addendum below.
2233
2234        G. Preserve in that license notice the full lists of Invariant
2235           Sections and required Cover Texts given in the Document's
2236           license notice.
2237
2238        H. Include an unaltered copy of this License.
2239
2240        I. Preserve the section Entitled "History", Preserve its Title,
2241           and add to it an item stating at least the title, year, new
2242           authors, and publisher of the Modified Version as given on the
2243           Title Page.  If there is no section Entitled "History" in the
2244           Document, create one stating the title, year, authors, and
2245           publisher of the Document as given on its Title Page, then add
2246           an item describing the Modified Version as stated in the
2247           previous sentence.
2248
2249        J. Preserve the network location, if any, given in the Document
2250           for public access to a Transparent copy of the Document, and
2251           likewise the network locations given in the Document for
2252           previous versions it was based on.  These may be placed in the
2253           "History" section.  You may omit a network location for a work
2254           that was published at least four years before the Document
2255           itself, or if the original publisher of the version it refers
2256           to gives permission.
2257
2258        K. For any section Entitled "Acknowledgements" or "Dedications",
2259           Preserve the Title of the section, and preserve in the section
2260           all the substance and tone of each of the contributor
2261           acknowledgements and/or dedications given therein.
2262
2263        L. Preserve all the Invariant Sections of the Document, unaltered
2264           in their text and in their titles.  Section numbers or the
2265           equivalent are not considered part of the section titles.
2266
2267        M. Delete any section Entitled "Endorsements".  Such a section
2268           may not be included in the Modified Version.
2269
2270        N. Do not retitle any existing section to be Entitled
2271           "Endorsements" or to conflict in title with any Invariant
2272           Section.
2273
2274        O. Preserve any Warranty Disclaimers.
2275
2276      If the Modified Version includes new front-matter sections or
2277      appendices that qualify as Secondary Sections and contain no
2278      material copied from the Document, you may at your option designate
2279      some or all of these sections as invariant.  To do this, add their
2280      titles to the list of Invariant Sections in the Modified Version's
2281      license notice.  These titles must be distinct from any other
2282      section titles.
2283
2284      You may add a section Entitled "Endorsements", provided it contains
2285      nothing but endorsements of your Modified Version by various
2286      parties--for example, statements of peer review or that the text
2287      has been approved by an organization as the authoritative
2288      definition of a standard.
2289
2290      You may add a passage of up to five words as a Front-Cover Text,
2291      and a passage of up to 25 words as a Back-Cover Text, to the end of
2292      the list of Cover Texts in the Modified Version.  Only one passage
2293      of Front-Cover Text and one of Back-Cover Text may be added by (or
2294      through arrangements made by) any one entity.  If the Document
2295      already includes a cover text for the same cover, previously added
2296      by you or by arrangement made by the same entity you are acting on
2297      behalf of, you may not add another; but you may replace the old
2298      one, on explicit permission from the previous publisher that added
2299      the old one.
2300
2301      The author(s) and publisher(s) of the Document do not by this
2302      License give permission to use their names for publicity for or to
2303      assert or imply endorsement of any Modified Version.
2304
2305   5. COMBINING DOCUMENTS
2306
2307      You may combine the Document with other documents released under
2308      this License, under the terms defined in section 4 above for
2309      modified versions, provided that you include in the combination all
2310      of the Invariant Sections of all of the original documents,
2311      unmodified, and list them all as Invariant Sections of your
2312      combined work in its license notice, and that you preserve all
2313      their Warranty Disclaimers.
2314
2315      The combined work need only contain one copy of this License, and
2316      multiple identical Invariant Sections may be replaced with a single
2317      copy.  If there are multiple Invariant Sections with the same name
2318      but different contents, make the title of each such section unique
2319      by adding at the end of it, in parentheses, the name of the
2320      original author or publisher of that section if known, or else a
2321      unique number.  Make the same adjustment to the section titles in
2322      the list of Invariant Sections in the license notice of the
2323      combined work.
2324
2325      In the combination, you must combine any sections Entitled
2326      "History" in the various original documents, forming one section
2327      Entitled "History"; likewise combine any sections Entitled
2328      "Acknowledgements", and any sections Entitled "Dedications".  You
2329      must delete all sections Entitled "Endorsements."
2330
2331   6. COLLECTIONS OF DOCUMENTS
2332
2333      You may make a collection consisting of the Document and other
2334      documents released under this License, and replace the individual
2335      copies of this License in the various documents with a single copy
2336      that is included in the collection, provided that you follow the
2337      rules of this License for verbatim copying of each of the documents
2338      in all other respects.
2339
2340      You may extract a single document from such a collection, and
2341      distribute it individually under this License, provided you insert
2342      a copy of this License into the extracted document, and follow this
2343      License in all other respects regarding verbatim copying of that
2344      document.
2345
2346   7. AGGREGATION WITH INDEPENDENT WORKS
2347
2348      A compilation of the Document or its derivatives with other
2349      separate and independent documents or works, in or on a volume of a
2350      storage or distribution medium, is called an "aggregate" if the
2351      copyright resulting from the compilation is not used to limit the
2352      legal rights of the compilation's users beyond what the individual
2353      works permit.  When the Document is included in an aggregate, this
2354      License does not apply to the other works in the aggregate which
2355      are not themselves derivative works of the Document.
2356
2357      If the Cover Text requirement of section 3 is applicable to these
2358      copies of the Document, then if the Document is less than one half
2359      of the entire aggregate, the Document's Cover Texts may be placed
2360      on covers that bracket the Document within the aggregate, or the
2361      electronic equivalent of covers if the Document is in electronic
2362      form.  Otherwise they must appear on printed covers that bracket
2363      the whole aggregate.
2364
2365   8. TRANSLATION
2366
2367      Translation is considered a kind of modification, so you may
2368      distribute translations of the Document under the terms of section
2369      4.  Replacing Invariant Sections with translations requires special
2370      permission from their copyright holders, but you may include
2371      translations of some or all Invariant Sections in addition to the
2372      original versions of these Invariant Sections.  You may include a
2373      translation of this License, and all the license notices in the
2374      Document, and any Warranty Disclaimers, provided that you also
2375      include the original English version of this License and the
2376      original versions of those notices and disclaimers.  In case of a
2377      disagreement between the translation and the original version of
2378      this License or a notice or disclaimer, the original version will
2379      prevail.
2380
2381      If a section in the Document is Entitled "Acknowledgements",
2382      "Dedications", or "History", the requirement (section 4) to
2383      Preserve its Title (section 1) will typically require changing the
2384      actual title.
2385
2386   9. TERMINATION
2387
2388      You may not copy, modify, sublicense, or distribute the Document
2389      except as expressly provided under this License.  Any attempt
2390      otherwise to copy, modify, sublicense, or distribute it is void,
2391      and will automatically terminate your rights under this License.
2392
2393      However, if you cease all violation of this License, then your
2394      license from a particular copyright holder is reinstated (a)
2395      provisionally, unless and until the copyright holder explicitly and
2396      finally terminates your license, and (b) permanently, if the
2397      copyright holder fails to notify you of the violation by some
2398      reasonable means prior to 60 days after the cessation.
2399
2400      Moreover, your license from a particular copyright holder is
2401      reinstated permanently if the copyright holder notifies you of the
2402      violation by some reasonable means, this is the first time you have
2403      received notice of violation of this License (for any work) from
2404      that copyright holder, and you cure the violation prior to 30 days
2405      after your receipt of the notice.
2406
2407      Termination of your rights under this section does not terminate
2408      the licenses of parties who have received copies or rights from you
2409      under this License.  If your rights have been terminated and not
2410      permanently reinstated, receipt of a copy of some or all of the
2411      same material does not give you any rights to use it.
2412
2413   10. FUTURE REVISIONS OF THIS LICENSE
2414
2415      The Free Software Foundation may publish new, revised versions of
2416      the GNU Free Documentation License from time to time.  Such new
2417      versions will be similar in spirit to the present version, but may
2418      differ in detail to address new problems or concerns.  See
2419      <https://www.gnu.org/copyleft/>.
2420
2421      Each version of the License is given a distinguishing version
2422      number.  If the Document specifies that a particular numbered
2423      version of this License "or any later version" applies to it, you
2424      have the option of following the terms and conditions either of
2425      that specified version or of any later version that has been
2426      published (not as a draft) by the Free Software Foundation.  If the
2427      Document does not specify a version number of this License, you may
2428      choose any version ever published (not as a draft) by the Free
2429      Software Foundation.  If the Document specifies that a proxy can
2430      decide which future versions of this License can be used, that
2431      proxy's public statement of acceptance of a version permanently
2432      authorizes you to choose that version for the Document.
2433
2434   11. RELICENSING
2435
2436      "Massive Multiauthor Collaboration Site" (or "MMC Site") means any
2437      World Wide Web server that publishes copyrightable works and also
2438      provides prominent facilities for anybody to edit those works.  A
2439      public wiki that anybody can edit is an example of such a server.
2440      A "Massive Multiauthor Collaboration" (or "MMC") contained in the
2441      site means any set of copyrightable works thus published on the MMC
2442      site.
2443
2444      "CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0
2445      license published by Creative Commons Corporation, a not-for-profit
2446      corporation with a principal place of business in San Francisco,
2447      California, as well as future copyleft versions of that license
2448      published by that same organization.
2449
2450      "Incorporate" means to publish or republish a Document, in whole or
2451      in part, as part of another Document.
2452
2453      An MMC is "eligible for relicensing" if it is licensed under this
2454      License, and if all works that were first published under this
2455      License somewhere other than this MMC, and subsequently
2456      incorporated in whole or in part into the MMC, (1) had no cover
2457      texts or invariant sections, and (2) were thus incorporated prior
2458      to November 1, 2008.
2459
2460      The operator of an MMC Site may republish an MMC contained in the
2461      site under CC-BY-SA on the same site at any time before August 1,
2462      2009, provided the MMC is eligible for relicensing.
2463
2464 ADDENDUM: How to use this License for your documents
2465 ====================================================
2466
2467 To use this License in a document you have written, include a copy of
2468 the License in the document and put the following copyright and license
2469 notices just after the title page:
2470
2471        Copyright (C)  YEAR  YOUR NAME.
2472        Permission is granted to copy, distribute and/or modify this document
2473        under the terms of the GNU Free Documentation License, Version 1.3
2474        or any later version published by the Free Software Foundation;
2475        with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
2476        Texts.  A copy of the license is included in the section entitled ``GNU
2477        Free Documentation License''.
2478
2479    If you have Invariant Sections, Front-Cover Texts and Back-Cover
2480 Texts, replace the "with...Texts."  line with this:
2481
2482          with the Invariant Sections being LIST THEIR TITLES, with
2483          the Front-Cover Texts being LIST, and with the Back-Cover Texts
2484          being LIST.
2485
2486    If you have Invariant Sections without Cover Texts, or some other
2487 combination of the three, merge those two alternatives to suit the
2488 situation.
2489
2490    If your document contains nontrivial examples of program code, we
2491 recommend releasing these examples in parallel under your choice of free
2492 software license, such as the GNU General Public License, to permit
2493 their use in free software.
2494
2495 \1f
2496 File: gmp.info,  Node: Concept Index,  Next: Function Index,  Prev: GNU Free Documentation License,  Up: Top
2497
2498 Concept Index
2499 *************
2500
2501 \0\b[index\0\b]
2502 * Menu:
2503
2504 * #include:                              Headers and Libraries.
2505                                                               (line   6)
2506 * --build:                               Build Options.       (line  51)
2507 * --disable-fft:                         Build Options.       (line 307)
2508 * --disable-shared:                      Build Options.       (line  44)
2509 * --disable-static:                      Build Options.       (line  44)
2510 * --enable-alloca:                       Build Options.       (line 273)
2511 * --enable-assert:                       Build Options.       (line 313)
2512 * --enable-cxx:                          Build Options.       (line 225)
2513 * --enable-fat:                          Build Options.       (line 160)
2514 * --enable-profiling:                    Build Options.       (line 317)
2515 * --enable-profiling <1>:                Profiling.           (line   6)
2516 * --exec-prefix:                         Build Options.       (line  32)
2517 * --host:                                Build Options.       (line  65)
2518 * --prefix:                              Build Options.       (line  32)
2519 * -finstrument-functions:                Profiling.           (line  66)
2520 * 2exp functions:                        Efficiency.          (line  43)
2521 * 68000:                                 Notes for Particular Systems.
2522                                                               (line  94)
2523 * 80x86:                                 Notes for Particular Systems.
2524                                                               (line 150)
2525 * ABI:                                   Build Options.       (line 167)
2526 * ABI <1>:                               ABI and ISA.         (line   6)
2527 * About this manual:                     Introduction to GMP. (line  57)
2528 * AC_CHECK_LIB:                          Autoconf.            (line  11)
2529 * AIX:                                   ABI and ISA.         (line 174)
2530 * AIX <1>:                               Notes for Particular Systems.
2531                                                               (line   7)
2532 * Algorithms:                            Algorithms.          (line   6)
2533 * alloca:                                Build Options.       (line 273)
2534 * Allocation of memory:                  Custom Allocation.   (line   6)
2535 * AMD64:                                 ABI and ISA.         (line  44)
2536 * Anonymous FTP of latest version:       Introduction to GMP. (line  37)
2537 * Application Binary Interface:          ABI and ISA.         (line   6)
2538 * Arithmetic functions:                  Integer Arithmetic.  (line   6)
2539 * Arithmetic functions <1>:              Rational Arithmetic. (line   6)
2540 * Arithmetic functions <2>:              Float Arithmetic.    (line   6)
2541 * ARM:                                   Notes for Particular Systems.
2542                                                               (line  20)
2543 * Assembly cache handling:               Assembly Cache Handling.
2544                                                               (line   6)
2545 * Assembly carry propagation:            Assembly Carry Propagation.
2546                                                               (line   6)
2547 * Assembly code organisation:            Assembly Code Organisation.
2548                                                               (line   6)
2549 * Assembly coding:                       Assembly Coding.     (line   6)
2550 * Assembly floating Point:               Assembly Floating Point.
2551                                                               (line   6)
2552 * Assembly loop unrolling:               Assembly Loop Unrolling.
2553                                                               (line   6)
2554 * Assembly SIMD:                         Assembly SIMD Instructions.
2555                                                               (line   6)
2556 * Assembly software pipelining:          Assembly Software Pipelining.
2557                                                               (line   6)
2558 * Assembly writing guide:                Assembly Writing Guide.
2559                                                               (line   6)
2560 * Assertion checking:                    Build Options.       (line 313)
2561 * Assertion checking <1>:                Debugging.           (line  74)
2562 * Assignment functions:                  Assigning Integers.  (line   6)
2563 * Assignment functions <1>:              Simultaneous Integer Init & Assign.
2564                                                               (line   6)
2565 * Assignment functions <2>:              Initializing Rationals.
2566                                                               (line   6)
2567 * Assignment functions <3>:              Assigning Floats.    (line   6)
2568 * Assignment functions <4>:              Simultaneous Float Init & Assign.
2569                                                               (line   6)
2570 * Autoconf:                              Autoconf.            (line   6)
2571 * Basics:                                GMP Basics.          (line   6)
2572 * Binomial coefficient algorithm:        Binomial Coefficients Algorithm.
2573                                                               (line   6)
2574 * Binomial coefficient functions:        Number Theoretic Functions.
2575                                                               (line 128)
2576 * Binutils strip:                        Known Build Problems.
2577                                                               (line  28)
2578 * Bit manipulation functions:            Integer Logic and Bit Fiddling.
2579                                                               (line   6)
2580 * Bit scanning functions:                Integer Logic and Bit Fiddling.
2581                                                               (line  39)
2582 * Bit shift left:                        Integer Arithmetic.  (line  38)
2583 * Bit shift right:                       Integer Division.    (line  74)
2584 * Bits per limb:                         Useful Macros and Constants.
2585                                                               (line   7)
2586 * Bug reporting:                         Reporting Bugs.      (line   6)
2587 * Build directory:                       Build Options.       (line  19)
2588 * Build notes for binary packaging:      Notes for Package Builds.
2589                                                               (line   6)
2590 * Build notes for particular systems:    Notes for Particular Systems.
2591                                                               (line   6)
2592 * Build options:                         Build Options.       (line   6)
2593 * Build problems known:                  Known Build Problems.
2594                                                               (line   6)
2595 * Build system:                          Build Options.       (line  51)
2596 * Building GMP:                          Installing GMP.      (line   6)
2597 * Bus error:                             Debugging.           (line   7)
2598 * C compiler:                            Build Options.       (line 178)
2599 * C++ compiler:                          Build Options.       (line 249)
2600 * C++ interface:                         C++ Class Interface. (line   6)
2601 * C++ interface internals:               C++ Interface Internals.
2602                                                               (line   6)
2603 * C++ istream input:                     C++ Formatted Input. (line   6)
2604 * C++ ostream output:                    C++ Formatted Output.
2605                                                               (line   6)
2606 * C++ support:                           Build Options.       (line 225)
2607 * CC:                                    Build Options.       (line 178)
2608 * CC_FOR_BUILD:                          Build Options.       (line 212)
2609 * CFLAGS:                                Build Options.       (line 178)
2610 * Checker:                               Debugging.           (line 110)
2611 * checkergcc:                            Debugging.           (line 117)
2612 * Code organisation:                     Assembly Code Organisation.
2613                                                               (line   6)
2614 * Compaq C++:                            Notes for Particular Systems.
2615                                                               (line  25)
2616 * Comparison functions:                  Integer Comparisons. (line   6)
2617 * Comparison functions <1>:              Comparing Rationals. (line   6)
2618 * Comparison functions <2>:              Float Comparison.    (line   6)
2619 * Compatibility with older versions:     Compatibility with older versions.
2620                                                               (line   6)
2621 * Conditions for copying GNU MP:         Copying.             (line   6)
2622 * Configuring GMP:                       Installing GMP.      (line   6)
2623 * Congruence algorithm:                  Exact Remainder.     (line  30)
2624 * Congruence functions:                  Integer Division.    (line 150)
2625 * Constants:                             Useful Macros and Constants.
2626                                                               (line   6)
2627 * Contributors:                          Contributors.        (line   6)
2628 * Conventions for parameters:            Parameter Conventions.
2629                                                               (line   6)
2630 * Conventions for variables:             Variable Conventions.
2631                                                               (line   6)
2632 * Conversion functions:                  Converting Integers. (line   6)
2633 * Conversion functions <1>:              Rational Conversions.
2634                                                               (line   6)
2635 * Conversion functions <2>:              Converting Floats.   (line   6)
2636 * Copying conditions:                    Copying.             (line   6)
2637 * CPPFLAGS:                              Build Options.       (line 204)
2638 * CPU types:                             Introduction to GMP. (line  24)
2639 * CPU types <1>:                         Build Options.       (line 107)
2640 * Cross compiling:                       Build Options.       (line  65)
2641 * Cryptography functions, low-level:     Low-level Functions. (line 507)
2642 * Custom allocation:                     Custom Allocation.   (line   6)
2643 * CXX:                                   Build Options.       (line 249)
2644 * CXXFLAGS:                              Build Options.       (line 249)
2645 * Cygwin:                                Notes for Particular Systems.
2646                                                               (line  57)
2647 * Darwin:                                Known Build Problems.
2648                                                               (line  51)
2649 * Debugging:                             Debugging.           (line   6)
2650 * Demonstration programs:                Demonstration Programs.
2651                                                               (line   6)
2652 * Digits in an integer:                  Miscellaneous Integer Functions.
2653                                                               (line  23)
2654 * Divisibility algorithm:                Exact Remainder.     (line  30)
2655 * Divisibility functions:                Integer Division.    (line 136)
2656 * Divisibility functions <1>:            Integer Division.    (line 150)
2657 * Divisibility testing:                  Efficiency.          (line  91)
2658 * Division algorithms:                   Division Algorithms. (line   6)
2659 * Division functions:                    Integer Division.    (line   6)
2660 * Division functions <1>:                Rational Arithmetic. (line  24)
2661 * Division functions <2>:                Float Arithmetic.    (line  33)
2662 * DJGPP:                                 Notes for Particular Systems.
2663                                                               (line  57)
2664 * DJGPP <1>:                             Known Build Problems.
2665                                                               (line  18)
2666 * DLLs:                                  Notes for Particular Systems.
2667                                                               (line  70)
2668 * DocBook:                               Build Options.       (line 340)
2669 * Documentation formats:                 Build Options.       (line 333)
2670 * Documentation license:                 GNU Free Documentation License.
2671                                                               (line   6)
2672 * DVI:                                   Build Options.       (line 336)
2673 * Efficiency:                            Efficiency.          (line   6)
2674 * Emacs:                                 Emacs.               (line   6)
2675 * Exact division functions:              Integer Division.    (line 125)
2676 * Exact remainder:                       Exact Remainder.     (line   6)
2677 * Example programs:                      Demonstration Programs.
2678                                                               (line   6)
2679 * Exec prefix:                           Build Options.       (line  32)
2680 * Execution profiling:                   Build Options.       (line 317)
2681 * Execution profiling <1>:               Profiling.           (line   6)
2682 * Exponentiation functions:              Integer Exponentiation.
2683                                                               (line   6)
2684 * Exponentiation functions <1>:          Float Arithmetic.    (line  41)
2685 * Export:                                Integer Import and Export.
2686                                                               (line  45)
2687 * Expression parsing demo:               Demonstration Programs.
2688                                                               (line  15)
2689 * Expression parsing demo <1>:           Demonstration Programs.
2690                                                               (line  17)
2691 * Expression parsing demo <2>:           Demonstration Programs.
2692                                                               (line  19)
2693 * Extended GCD:                          Number Theoretic Functions.
2694                                                               (line  47)
2695 * Factor removal functions:              Number Theoretic Functions.
2696                                                               (line 108)
2697 * Factorial algorithm:                   Factorial Algorithm. (line   6)
2698 * Factorial functions:                   Number Theoretic Functions.
2699                                                               (line 116)
2700 * Factorization demo:                    Demonstration Programs.
2701                                                               (line  22)
2702 * Fast Fourier Transform:                FFT Multiplication.  (line   6)
2703 * Fat binary:                            Build Options.       (line 160)
2704 * FFT multiplication:                    Build Options.       (line 307)
2705 * FFT multiplication <1>:                FFT Multiplication.  (line   6)
2706 * Fibonacci number algorithm:            Fibonacci Numbers Algorithm.
2707                                                               (line   6)
2708 * Fibonacci sequence functions:          Number Theoretic Functions.
2709                                                               (line 136)
2710 * Float arithmetic functions:            Float Arithmetic.    (line   6)
2711 * Float assignment functions:            Assigning Floats.    (line   6)
2712 * Float assignment functions <1>:        Simultaneous Float Init & Assign.
2713                                                               (line   6)
2714 * Float comparison functions:            Float Comparison.    (line   6)
2715 * Float conversion functions:            Converting Floats.   (line   6)
2716 * Float functions:                       Floating-point Functions.
2717                                                               (line   6)
2718 * Float initialization functions:        Initializing Floats. (line   6)
2719 * Float initialization functions <1>:    Simultaneous Float Init & Assign.
2720                                                               (line   6)
2721 * Float input and output functions:      I/O of Floats.       (line   6)
2722 * Float internals:                       Float Internals.     (line   6)
2723 * Float miscellaneous functions:         Miscellaneous Float Functions.
2724                                                               (line   6)
2725 * Float random number functions:         Miscellaneous Float Functions.
2726                                                               (line  27)
2727 * Float rounding functions:              Miscellaneous Float Functions.
2728                                                               (line   9)
2729 * Float sign tests:                      Float Comparison.    (line  34)
2730 * Floating point mode:                   Notes for Particular Systems.
2731                                                               (line  34)
2732 * Floating-point functions:              Floating-point Functions.
2733                                                               (line   6)
2734 * Floating-point number:                 Nomenclature and Types.
2735                                                               (line  21)
2736 * fnccheck:                              Profiling.           (line  77)
2737 * Formatted input:                       Formatted Input.     (line   6)
2738 * Formatted output:                      Formatted Output.    (line   6)
2739 * Free Documentation License:            GNU Free Documentation License.
2740                                                               (line   6)
2741 * FreeBSD:                               Notes for Particular Systems.
2742                                                               (line  43)
2743 * FreeBSD <1>:                           Notes for Particular Systems.
2744                                                               (line  52)
2745 * frexp:                                 Converting Integers. (line  43)
2746 * frexp <1>:                             Converting Floats.   (line  24)
2747 * FTP of latest version:                 Introduction to GMP. (line  37)
2748 * Function classes:                      Function Classes.    (line   6)
2749 * FunctionCheck:                         Profiling.           (line  77)
2750 * GCC Checker:                           Debugging.           (line 110)
2751 * GCD algorithms:                        Greatest Common Divisor Algorithms.
2752                                                               (line   6)
2753 * GCD extended:                          Number Theoretic Functions.
2754                                                               (line  47)
2755 * GCD functions:                         Number Theoretic Functions.
2756                                                               (line  30)
2757 * GDB:                                   Debugging.           (line  53)
2758 * Generic C:                             Build Options.       (line 151)
2759 * GMP Perl module:                       Demonstration Programs.
2760                                                               (line  28)
2761 * GMP version number:                    Useful Macros and Constants.
2762                                                               (line  12)
2763 * gmp.h:                                 Headers and Libraries.
2764                                                               (line   6)
2765 * gmpxx.h:                               C++ Interface General.
2766                                                               (line   8)
2767 * GNU Debugger:                          Debugging.           (line  53)
2768 * GNU Free Documentation License:        GNU Free Documentation License.
2769                                                               (line   6)
2770 * GNU strip:                             Known Build Problems.
2771                                                               (line  28)
2772 * gprof:                                 Profiling.           (line  41)
2773 * Greatest common divisor algorithms:    Greatest Common Divisor Algorithms.
2774                                                               (line   6)
2775 * Greatest common divisor functions:     Number Theoretic Functions.
2776                                                               (line  30)
2777 * Hardware floating point mode:          Notes for Particular Systems.
2778                                                               (line  34)
2779 * Headers:                               Headers and Libraries.
2780                                                               (line   6)
2781 * Heap problems:                         Debugging.           (line  23)
2782 * Home page:                             Introduction to GMP. (line  33)
2783 * Host system:                           Build Options.       (line  65)
2784 * HP-UX:                                 ABI and ISA.         (line  76)
2785 * HP-UX <1>:                             ABI and ISA.         (line 114)
2786 * HPPA:                                  ABI and ISA.         (line  76)
2787 * I/O functions:                         I/O of Integers.     (line   6)
2788 * I/O functions <1>:                     I/O of Rationals.    (line   6)
2789 * I/O functions <2>:                     I/O of Floats.       (line   6)
2790 * i386:                                  Notes for Particular Systems.
2791                                                               (line 150)
2792 * IA-64:                                 ABI and ISA.         (line 114)
2793 * Import:                                Integer Import and Export.
2794                                                               (line  11)
2795 * In-place operations:                   Efficiency.          (line  57)
2796 * Include files:                         Headers and Libraries.
2797                                                               (line   6)
2798 * info-lookup-symbol:                    Emacs.               (line   6)
2799 * Initialization functions:              Initializing Integers.
2800                                                               (line   6)
2801 * Initialization functions <1>:          Simultaneous Integer Init & Assign.
2802                                                               (line   6)
2803 * Initialization functions <2>:          Initializing Rationals.
2804                                                               (line   6)
2805 * Initialization functions <3>:          Initializing Floats. (line   6)
2806 * Initialization functions <4>:          Simultaneous Float Init & Assign.
2807                                                               (line   6)
2808 * Initialization functions <5>:          Random State Initialization.
2809                                                               (line   6)
2810 * Initializing and clearing:             Efficiency.          (line  21)
2811 * Input functions:                       I/O of Integers.     (line   6)
2812 * Input functions <1>:                   I/O of Rationals.    (line   6)
2813 * Input functions <2>:                   I/O of Floats.       (line   6)
2814 * Input functions <3>:                   Formatted Input Functions.
2815                                                               (line   6)
2816 * Install prefix:                        Build Options.       (line  32)
2817 * Installing GMP:                        Installing GMP.      (line   6)
2818 * Instruction Set Architecture:          ABI and ISA.         (line   6)
2819 * instrument-functions:                  Profiling.           (line  66)
2820 * Integer:                               Nomenclature and Types.
2821                                                               (line   6)
2822 * Integer arithmetic functions:          Integer Arithmetic.  (line   6)
2823 * Integer assignment functions:          Assigning Integers.  (line   6)
2824 * Integer assignment functions <1>:      Simultaneous Integer Init & Assign.
2825                                                               (line   6)
2826 * Integer bit manipulation functions:    Integer Logic and Bit Fiddling.
2827                                                               (line   6)
2828 * Integer comparison functions:          Integer Comparisons. (line   6)
2829 * Integer conversion functions:          Converting Integers. (line   6)
2830 * Integer division functions:            Integer Division.    (line   6)
2831 * Integer exponentiation functions:      Integer Exponentiation.
2832                                                               (line   6)
2833 * Integer export:                        Integer Import and Export.
2834                                                               (line  45)
2835 * Integer functions:                     Integer Functions.   (line   6)
2836 * Integer import:                        Integer Import and Export.
2837                                                               (line  11)
2838 * Integer initialization functions:      Initializing Integers.
2839                                                               (line   6)
2840 * Integer initialization functions <1>:  Simultaneous Integer Init & Assign.
2841                                                               (line   6)
2842 * Integer input and output functions:    I/O of Integers.     (line   6)
2843 * Integer internals:                     Integer Internals.   (line   6)
2844 * Integer logical functions:             Integer Logic and Bit Fiddling.
2845                                                               (line   6)
2846 * Integer miscellaneous functions:       Miscellaneous Integer Functions.
2847                                                               (line   6)
2848 * Integer random number functions:       Integer Random Numbers.
2849                                                               (line   6)
2850 * Integer root functions:                Integer Roots.       (line   6)
2851 * Integer sign tests:                    Integer Comparisons. (line  28)
2852 * Integer special functions:             Integer Special Functions.
2853                                                               (line   6)
2854 * Interix:                               Notes for Particular Systems.
2855                                                               (line  65)
2856 * Internals:                             Internals.           (line   6)
2857 * Introduction:                          Introduction to GMP. (line   6)
2858 * Inverse modulo functions:              Number Theoretic Functions.
2859                                                               (line  74)
2860 * IRIX:                                  ABI and ISA.         (line 139)
2861 * IRIX <1>:                              Known Build Problems.
2862                                                               (line  38)
2863 * ISA:                                   ABI and ISA.         (line   6)
2864 * istream input:                         C++ Formatted Input. (line   6)
2865 * Jacobi symbol algorithm:               Jacobi Symbol.       (line   6)
2866 * Jacobi symbol functions:               Number Theoretic Functions.
2867                                                               (line  83)
2868 * Karatsuba multiplication:              Karatsuba Multiplication.
2869                                                               (line   6)
2870 * Karatsuba square root algorithm:       Square Root Algorithm.
2871                                                               (line   6)
2872 * Kronecker symbol functions:            Number Theoretic Functions.
2873                                                               (line  95)
2874 * Language bindings:                     Language Bindings.   (line   6)
2875 * Latest version of GMP:                 Introduction to GMP. (line  37)
2876 * LCM functions:                         Number Theoretic Functions.
2877                                                               (line  68)
2878 * Least common multiple functions:       Number Theoretic Functions.
2879                                                               (line  68)
2880 * Legendre symbol functions:             Number Theoretic Functions.
2881                                                               (line  86)
2882 * libgmp:                                Headers and Libraries.
2883                                                               (line  22)
2884 * libgmpxx:                              Headers and Libraries.
2885                                                               (line  27)
2886 * Libraries:                             Headers and Libraries.
2887                                                               (line  22)
2888 * Libtool:                               Headers and Libraries.
2889                                                               (line  33)
2890 * Libtool versioning:                    Notes for Package Builds.
2891                                                               (line   9)
2892 * License conditions:                    Copying.             (line   6)
2893 * Limb:                                  Nomenclature and Types.
2894                                                               (line  31)
2895 * Limb size:                             Useful Macros and Constants.
2896                                                               (line   7)
2897 * Linear congruential algorithm:         Random Number Algorithms.
2898                                                               (line  25)
2899 * Linear congruential random numbers:    Random State Initialization.
2900                                                               (line  18)
2901 * Linear congruential random numbers <1>: Random State Initialization.
2902                                                               (line  32)
2903 * Linking:                               Headers and Libraries.
2904                                                               (line  22)
2905 * Logical functions:                     Integer Logic and Bit Fiddling.
2906                                                               (line   6)
2907 * Low-level functions:                   Low-level Functions. (line   6)
2908 * Low-level functions for cryptography:  Low-level Functions. (line 507)
2909 * Lucas number algorithm:                Lucas Numbers Algorithm.
2910                                                               (line   6)
2911 * Lucas number functions:                Number Theoretic Functions.
2912                                                               (line 147)
2913 * MacOS X:                               Known Build Problems.
2914                                                               (line  51)
2915 * Mailing lists:                         Introduction to GMP. (line  44)
2916 * Malloc debugger:                       Debugging.           (line  29)
2917 * Malloc problems:                       Debugging.           (line  23)
2918 * Memory allocation:                     Custom Allocation.   (line   6)
2919 * Memory management:                     Memory Management.   (line   6)
2920 * Mersenne twister algorithm:            Random Number Algorithms.
2921                                                               (line  17)
2922 * Mersenne twister random numbers:       Random State Initialization.
2923                                                               (line  13)
2924 * MINGW:                                 Notes for Particular Systems.
2925                                                               (line  57)
2926 * MIPS:                                  ABI and ISA.         (line 139)
2927 * Miscellaneous float functions:         Miscellaneous Float Functions.
2928                                                               (line   6)
2929 * Miscellaneous integer functions:       Miscellaneous Integer Functions.
2930                                                               (line   6)
2931 * MMX:                                   Notes for Particular Systems.
2932                                                               (line 156)
2933 * Modular inverse functions:             Number Theoretic Functions.
2934                                                               (line  74)
2935 * Most significant bit:                  Miscellaneous Integer Functions.
2936                                                               (line  34)
2937 * MPN_PATH:                              Build Options.       (line 321)
2938 * MS Windows:                            Notes for Particular Systems.
2939                                                               (line  57)
2940 * MS Windows <1>:                        Notes for Particular Systems.
2941                                                               (line  70)
2942 * MS-DOS:                                Notes for Particular Systems.
2943                                                               (line  57)
2944 * Multi-threading:                       Reentrancy.          (line   6)
2945 * Multiplication algorithms:             Multiplication Algorithms.
2946                                                               (line   6)
2947 * Nails:                                 Low-level Functions. (line 686)
2948 * Native compilation:                    Build Options.       (line  51)
2949 * NetBSD:                                Notes for Particular Systems.
2950                                                               (line 100)
2951 * NeXT:                                  Known Build Problems.
2952                                                               (line  57)
2953 * Next prime function:                   Number Theoretic Functions.
2954                                                               (line  23)
2955 * Nomenclature:                          Nomenclature and Types.
2956                                                               (line   6)
2957 * Non-Unix systems:                      Build Options.       (line  11)
2958 * Nth root algorithm:                    Nth Root Algorithm.  (line   6)
2959 * Number sequences:                      Efficiency.          (line 145)
2960 * Number theoretic functions:            Number Theoretic Functions.
2961                                                               (line   6)
2962 * Numerator and denominator:             Applying Integer Functions.
2963                                                               (line   6)
2964 * obstack output:                        Formatted Output Functions.
2965                                                               (line  79)
2966 * OpenBSD:                               Notes for Particular Systems.
2967                                                               (line 109)
2968 * Optimizing performance:                Performance optimization.
2969                                                               (line   6)
2970 * ostream output:                        C++ Formatted Output.
2971                                                               (line   6)
2972 * Other languages:                       Language Bindings.   (line   6)
2973 * Output functions:                      I/O of Integers.     (line   6)
2974 * Output functions <1>:                  I/O of Rationals.    (line   6)
2975 * Output functions <2>:                  I/O of Floats.       (line   6)
2976 * Output functions <3>:                  Formatted Output Functions.
2977                                                               (line   6)
2978 * Packaged builds:                       Notes for Package Builds.
2979                                                               (line   6)
2980 * Parameter conventions:                 Parameter Conventions.
2981                                                               (line   6)
2982 * Parsing expressions demo:              Demonstration Programs.
2983                                                               (line  15)
2984 * Parsing expressions demo <1>:          Demonstration Programs.
2985                                                               (line  17)
2986 * Parsing expressions demo <2>:          Demonstration Programs.
2987                                                               (line  19)
2988 * Particular systems:                    Notes for Particular Systems.
2989                                                               (line   6)
2990 * Past GMP versions:                     Compatibility with older versions.
2991                                                               (line   6)
2992 * PDF:                                   Build Options.       (line 336)
2993 * Perfect power algorithm:               Perfect Power Algorithm.
2994                                                               (line   6)
2995 * Perfect power functions:               Integer Roots.       (line  28)
2996 * Perfect square algorithm:              Perfect Square Algorithm.
2997                                                               (line   6)
2998 * Perfect square functions:              Integer Roots.       (line  37)
2999 * perl:                                  Demonstration Programs.
3000                                                               (line  28)
3001 * Perl module:                           Demonstration Programs.
3002                                                               (line  28)
3003 * Postscript:                            Build Options.       (line 336)
3004 * Power/PowerPC:                         Notes for Particular Systems.
3005                                                               (line 115)
3006 * Power/PowerPC <1>:                     Known Build Problems.
3007                                                               (line  63)
3008 * Powering algorithms:                   Powering Algorithms. (line   6)
3009 * Powering functions:                    Integer Exponentiation.
3010                                                               (line   6)
3011 * Powering functions <1>:                Float Arithmetic.    (line  41)
3012 * PowerPC:                               ABI and ISA.         (line 173)
3013 * Precision of floats:                   Floating-point Functions.
3014                                                               (line   6)
3015 * Precision of hardware floating point:  Notes for Particular Systems.
3016                                                               (line  34)
3017 * Prefix:                                Build Options.       (line  32)
3018 * Prime testing algorithms:              Prime Testing Algorithm.
3019                                                               (line   6)
3020 * Prime testing functions:               Number Theoretic Functions.
3021                                                               (line   7)
3022 * Primorial functions:                   Number Theoretic Functions.
3023                                                               (line 121)
3024 * printf formatted output:               Formatted Output.    (line   6)
3025 * Probable prime testing functions:      Number Theoretic Functions.
3026                                                               (line   7)
3027 * prof:                                  Profiling.           (line  24)
3028 * Profiling:                             Profiling.           (line   6)
3029 * Radix conversion algorithms:           Radix Conversion Algorithms.
3030                                                               (line   6)
3031 * Random number algorithms:              Random Number Algorithms.
3032                                                               (line   6)
3033 * Random number functions:               Integer Random Numbers.
3034                                                               (line   6)
3035 * Random number functions <1>:           Miscellaneous Float Functions.
3036                                                               (line  27)
3037 * Random number functions <2>:           Random Number Functions.
3038                                                               (line   6)
3039 * Random number seeding:                 Random State Seeding.
3040                                                               (line   6)
3041 * Random number state:                   Random State Initialization.
3042                                                               (line   6)
3043 * Random state:                          Nomenclature and Types.
3044                                                               (line  46)
3045 * Rational arithmetic:                   Efficiency.          (line 111)
3046 * Rational arithmetic functions:         Rational Arithmetic. (line   6)
3047 * Rational assignment functions:         Initializing Rationals.
3048                                                               (line   6)
3049 * Rational comparison functions:         Comparing Rationals. (line   6)
3050 * Rational conversion functions:         Rational Conversions.
3051                                                               (line   6)
3052 * Rational initialization functions:     Initializing Rationals.
3053                                                               (line   6)
3054 * Rational input and output functions:   I/O of Rationals.    (line   6)
3055 * Rational internals:                    Rational Internals.  (line   6)
3056 * Rational number:                       Nomenclature and Types.
3057                                                               (line  16)
3058 * Rational number functions:             Rational Number Functions.
3059                                                               (line   6)
3060 * Rational numerator and denominator:    Applying Integer Functions.
3061                                                               (line   6)
3062 * Rational sign tests:                   Comparing Rationals. (line  28)
3063 * Raw output internals:                  Raw Output Internals.
3064                                                               (line   6)
3065 * Reallocations:                         Efficiency.          (line  30)
3066 * Reentrancy:                            Reentrancy.          (line   6)
3067 * References:                            References.          (line   5)
3068 * Remove factor functions:               Number Theoretic Functions.
3069                                                               (line 108)
3070 * Reporting bugs:                        Reporting Bugs.      (line   6)
3071 * Root extraction algorithm:             Nth Root Algorithm.  (line   6)
3072 * Root extraction algorithms:            Root Extraction Algorithms.
3073                                                               (line   6)
3074 * Root extraction functions:             Integer Roots.       (line   6)
3075 * Root extraction functions <1>:         Float Arithmetic.    (line  37)
3076 * Root testing functions:                Integer Roots.       (line  28)
3077 * Root testing functions <1>:            Integer Roots.       (line  37)
3078 * Rounding functions:                    Miscellaneous Float Functions.
3079                                                               (line   9)
3080 * Sample programs:                       Demonstration Programs.
3081                                                               (line   6)
3082 * Scan bit functions:                    Integer Logic and Bit Fiddling.
3083                                                               (line  39)
3084 * scanf formatted input:                 Formatted Input.     (line   6)
3085 * SCO:                                   Known Build Problems.
3086                                                               (line  38)
3087 * Seeding random numbers:                Random State Seeding.
3088                                                               (line   6)
3089 * Segmentation violation:                Debugging.           (line   7)
3090 * Sequent Symmetry:                      Known Build Problems.
3091                                                               (line  68)
3092 * Services for Unix:                     Notes for Particular Systems.
3093                                                               (line  65)
3094 * Shared library versioning:             Notes for Package Builds.
3095                                                               (line   9)
3096 * Sign tests:                            Integer Comparisons. (line  28)
3097 * Sign tests <1>:                        Comparing Rationals. (line  28)
3098 * Sign tests <2>:                        Float Comparison.    (line  34)
3099 * Size in digits:                        Miscellaneous Integer Functions.
3100                                                               (line  23)
3101 * Small operands:                        Efficiency.          (line   7)
3102 * Solaris:                               ABI and ISA.         (line 204)
3103 * Solaris <1>:                           Known Build Problems.
3104                                                               (line  72)
3105 * Solaris <2>:                           Known Build Problems.
3106                                                               (line  77)
3107 * Sparc:                                 Notes for Particular Systems.
3108                                                               (line 127)
3109 * Sparc <1>:                             Notes for Particular Systems.
3110                                                               (line 132)
3111 * Sparc V9:                              ABI and ISA.         (line 204)
3112 * Special integer functions:             Integer Special Functions.
3113                                                               (line   6)
3114 * Square root algorithm:                 Square Root Algorithm.
3115                                                               (line   6)
3116 * SSE2:                                  Notes for Particular Systems.
3117                                                               (line 156)
3118 * Stack backtrace:                       Debugging.           (line  45)
3119 * Stack overflow:                        Build Options.       (line 273)
3120 * Stack overflow <1>:                    Debugging.           (line   7)
3121 * Static linking:                        Efficiency.          (line  14)
3122 * stdarg.h:                              Headers and Libraries.
3123                                                               (line  17)
3124 * stdio.h:                               Headers and Libraries.
3125                                                               (line  11)
3126 * Stripped libraries:                    Known Build Problems.
3127                                                               (line  28)
3128 * Sun:                                   ABI and ISA.         (line 204)
3129 * SunOS:                                 Notes for Particular Systems.
3130                                                               (line 144)
3131 * Systems:                               Notes for Particular Systems.
3132                                                               (line   6)
3133 * Temporary memory:                      Build Options.       (line 273)
3134 * Texinfo:                               Build Options.       (line 333)
3135 * Text input/output:                     Efficiency.          (line 151)
3136 * Thread safety:                         Reentrancy.          (line   6)
3137 * Toom multiplication:                   Toom 3-Way Multiplication.
3138                                                               (line   6)
3139 * Toom multiplication <1>:               Toom 4-Way Multiplication.
3140                                                               (line   6)
3141 * Toom multiplication <2>:               Higher degree Toom'n'half.
3142                                                               (line   6)
3143 * Toom multiplication <3>:               Other Multiplication.
3144                                                               (line   6)
3145 * Types:                                 Nomenclature and Types.
3146                                                               (line   6)
3147 * ui and si functions:                   Efficiency.          (line  50)
3148 * Unbalanced multiplication:             Unbalanced Multiplication.
3149                                                               (line   6)
3150 * Upward compatibility:                  Compatibility with older versions.
3151                                                               (line   6)
3152 * Useful macros and constants:           Useful Macros and Constants.
3153                                                               (line   6)
3154 * User-defined precision:                Floating-point Functions.
3155                                                               (line   6)
3156 * Valgrind:                              Debugging.           (line 125)
3157 * Variable conventions:                  Variable Conventions.
3158                                                               (line   6)
3159 * Version number:                        Useful Macros and Constants.
3160                                                               (line  12)
3161 * Web page:                              Introduction to GMP. (line  33)
3162 * Windows:                               Notes for Particular Systems.
3163                                                               (line  57)
3164 * Windows <1>:                           Notes for Particular Systems.
3165                                                               (line  70)
3166 * x86:                                   Notes for Particular Systems.
3167                                                               (line 150)
3168 * x87:                                   Notes for Particular Systems.
3169                                                               (line  34)
3170 * XML:                                   Build Options.       (line 340)
3171
3172 \1f
3173 File: gmp.info,  Node: Function Index,  Prev: Concept Index,  Up: Top
3174
3175 Function and Type Index
3176 ***********************
3177
3178 \0\b[index\0\b]
3179 * Menu:
3180
3181 * _mpz_realloc:                          Integer Special Functions.
3182                                                               (line  13)
3183 * __GMP_CC:                              Useful Macros and Constants.
3184                                                               (line  22)
3185 * __GMP_CFLAGS:                          Useful Macros and Constants.
3186                                                               (line  23)
3187 * __GNU_MP_VERSION:                      Useful Macros and Constants.
3188                                                               (line   9)
3189 * __GNU_MP_VERSION_MINOR:                Useful Macros and Constants.
3190                                                               (line  10)
3191 * __GNU_MP_VERSION_PATCHLEVEL:           Useful Macros and Constants.
3192                                                               (line  11)
3193 * abs:                                   C++ Interface Integers.
3194                                                               (line  46)
3195 * abs <1>:                               C++ Interface Rationals.
3196                                                               (line  47)
3197 * abs <2>:                               C++ Interface Floats.
3198                                                               (line  82)
3199 * ceil:                                  C++ Interface Floats.
3200                                                               (line  83)
3201 * cmp:                                   C++ Interface Integers.
3202                                                               (line  47)
3203 * cmp <1>:                               C++ Interface Integers.
3204                                                               (line  48)
3205 * cmp <2>:                               C++ Interface Rationals.
3206                                                               (line  48)
3207 * cmp <3>:                               C++ Interface Rationals.
3208                                                               (line  49)
3209 * cmp <4>:                               C++ Interface Floats.
3210                                                               (line  84)
3211 * cmp <5>:                               C++ Interface Floats.
3212                                                               (line  85)
3213 * factorial:                             C++ Interface Integers.
3214                                                               (line  71)
3215 * fibonacci:                             C++ Interface Integers.
3216                                                               (line  75)
3217 * floor:                                 C++ Interface Floats.
3218                                                               (line  95)
3219 * gcd:                                   C++ Interface Integers.
3220                                                               (line  68)
3221 * gmp_asprintf:                          Formatted Output Functions.
3222                                                               (line  63)
3223 * gmp_errno:                             Random State Initialization.
3224                                                               (line  56)
3225 * GMP_ERROR_INVALID_ARGUMENT:            Random State Initialization.
3226                                                               (line  56)
3227 * GMP_ERROR_UNSUPPORTED_ARGUMENT:        Random State Initialization.
3228                                                               (line  56)
3229 * gmp_fprintf:                           Formatted Output Functions.
3230                                                               (line  28)
3231 * gmp_fscanf:                            Formatted Input Functions.
3232                                                               (line  24)
3233 * GMP_LIMB_BITS:                         Low-level Functions. (line 714)
3234 * GMP_NAIL_BITS:                         Low-level Functions. (line 712)
3235 * GMP_NAIL_MASK:                         Low-level Functions. (line 722)
3236 * GMP_NUMB_BITS:                         Low-level Functions. (line 713)
3237 * GMP_NUMB_MASK:                         Low-level Functions. (line 723)
3238 * GMP_NUMB_MAX:                          Low-level Functions. (line 731)
3239 * gmp_obstack_printf:                    Formatted Output Functions.
3240                                                               (line  75)
3241 * gmp_obstack_vprintf:                   Formatted Output Functions.
3242                                                               (line  77)
3243 * gmp_printf:                            Formatted Output Functions.
3244                                                               (line  23)
3245 * gmp_randclass:                         C++ Interface Random Numbers.
3246                                                               (line   6)
3247 * gmp_randclass::get_f:                  C++ Interface Random Numbers.
3248                                                               (line  44)
3249 * gmp_randclass::get_f <1>:              C++ Interface Random Numbers.
3250                                                               (line  45)
3251 * gmp_randclass::get_z_bits:             C++ Interface Random Numbers.
3252                                                               (line  37)
3253 * gmp_randclass::get_z_bits <1>:         C++ Interface Random Numbers.
3254                                                               (line  38)
3255 * gmp_randclass::get_z_range:            C++ Interface Random Numbers.
3256                                                               (line  41)
3257 * gmp_randclass::gmp_randclass:          C++ Interface Random Numbers.
3258                                                               (line  11)
3259 * gmp_randclass::gmp_randclass <1>:      C++ Interface Random Numbers.
3260                                                               (line  26)
3261 * gmp_randclass::seed:                   C++ Interface Random Numbers.
3262                                                               (line  32)
3263 * gmp_randclass::seed <1>:               C++ Interface Random Numbers.
3264                                                               (line  33)
3265 * gmp_randclear:                         Random State Initialization.
3266                                                               (line  62)
3267 * gmp_randinit:                          Random State Initialization.
3268                                                               (line  45)
3269 * gmp_randinit_default:                  Random State Initialization.
3270                                                               (line   6)
3271 * gmp_randinit_lc_2exp:                  Random State Initialization.
3272                                                               (line  16)
3273 * gmp_randinit_lc_2exp_size:             Random State Initialization.
3274                                                               (line  30)
3275 * gmp_randinit_mt:                       Random State Initialization.
3276                                                               (line  12)
3277 * gmp_randinit_set:                      Random State Initialization.
3278                                                               (line  41)
3279 * gmp_randseed:                          Random State Seeding.
3280                                                               (line   6)
3281 * gmp_randseed_ui:                       Random State Seeding.
3282                                                               (line   8)
3283 * gmp_randstate_t:                       Nomenclature and Types.
3284                                                               (line  46)
3285 * GMP_RAND_ALG_DEFAULT:                  Random State Initialization.
3286                                                               (line  50)
3287 * GMP_RAND_ALG_LC:                       Random State Initialization.
3288                                                               (line  50)
3289 * gmp_scanf:                             Formatted Input Functions.
3290                                                               (line  20)
3291 * gmp_snprintf:                          Formatted Output Functions.
3292                                                               (line  44)
3293 * gmp_sprintf:                           Formatted Output Functions.
3294                                                               (line  33)
3295 * gmp_sscanf:                            Formatted Input Functions.
3296                                                               (line  28)
3297 * gmp_urandomb_ui:                       Random State Miscellaneous.
3298                                                               (line   6)
3299 * gmp_urandomm_ui:                       Random State Miscellaneous.
3300                                                               (line  12)
3301 * gmp_vasprintf:                         Formatted Output Functions.
3302                                                               (line  64)
3303 * gmp_version:                           Useful Macros and Constants.
3304                                                               (line  18)
3305 * gmp_vfprintf:                          Formatted Output Functions.
3306                                                               (line  29)
3307 * gmp_vfscanf:                           Formatted Input Functions.
3308                                                               (line  25)
3309 * gmp_vprintf:                           Formatted Output Functions.
3310                                                               (line  24)
3311 * gmp_vscanf:                            Formatted Input Functions.
3312                                                               (line  21)
3313 * gmp_vsnprintf:                         Formatted Output Functions.
3314                                                               (line  46)
3315 * gmp_vsprintf:                          Formatted Output Functions.
3316                                                               (line  34)
3317 * gmp_vsscanf:                           Formatted Input Functions.
3318                                                               (line  29)
3319 * hypot:                                 C++ Interface Floats.
3320                                                               (line  96)
3321 * lcm:                                   C++ Interface Integers.
3322                                                               (line  69)
3323 * mpf_abs:                               Float Arithmetic.    (line  46)
3324 * mpf_add:                               Float Arithmetic.    (line   6)
3325 * mpf_add_ui:                            Float Arithmetic.    (line   7)
3326 * mpf_ceil:                              Miscellaneous Float Functions.
3327                                                               (line   6)
3328 * mpf_class:                             C++ Interface General.
3329                                                               (line  19)
3330 * mpf_class::fits_sint_p:                C++ Interface Floats.
3331                                                               (line  87)
3332 * mpf_class::fits_slong_p:               C++ Interface Floats.
3333                                                               (line  88)
3334 * mpf_class::fits_sshort_p:              C++ Interface Floats.
3335                                                               (line  89)
3336 * mpf_class::fits_uint_p:                C++ Interface Floats.
3337                                                               (line  91)
3338 * mpf_class::fits_ulong_p:               C++ Interface Floats.
3339                                                               (line  92)
3340 * mpf_class::fits_ushort_p:              C++ Interface Floats.
3341                                                               (line  93)
3342 * mpf_class::get_d:                      C++ Interface Floats.
3343                                                               (line  98)
3344 * mpf_class::get_mpf_t:                  C++ Interface General.
3345                                                               (line  65)
3346 * mpf_class::get_prec:                   C++ Interface Floats.
3347                                                               (line 120)
3348 * mpf_class::get_si:                     C++ Interface Floats.
3349                                                               (line  99)
3350 * mpf_class::get_str:                    C++ Interface Floats.
3351                                                               (line 100)
3352 * mpf_class::get_ui:                     C++ Interface Floats.
3353                                                               (line 102)
3354 * mpf_class::mpf_class:                  C++ Interface Floats.
3355                                                               (line  11)
3356 * mpf_class::mpf_class <1>:              C++ Interface Floats.
3357                                                               (line  12)
3358 * mpf_class::mpf_class <2>:              C++ Interface Floats.
3359                                                               (line  32)
3360 * mpf_class::mpf_class <3>:              C++ Interface Floats.
3361                                                               (line  33)
3362 * mpf_class::mpf_class <4>:              C++ Interface Floats.
3363                                                               (line  41)
3364 * mpf_class::mpf_class <5>:              C++ Interface Floats.
3365                                                               (line  42)
3366 * mpf_class::mpf_class <6>:              C++ Interface Floats.
3367                                                               (line  44)
3368 * mpf_class::mpf_class <7>:              C++ Interface Floats.
3369                                                               (line  45)
3370 * mpf_class::operator=:                  C++ Interface Floats.
3371                                                               (line  59)
3372 * mpf_class::set_prec:                   C++ Interface Floats.
3373                                                               (line 121)
3374 * mpf_class::set_prec_raw:               C++ Interface Floats.
3375                                                               (line 122)
3376 * mpf_class::set_str:                    C++ Interface Floats.
3377                                                               (line 104)
3378 * mpf_class::set_str <1>:                C++ Interface Floats.
3379                                                               (line 105)
3380 * mpf_class::swap:                       C++ Interface Floats.
3381                                                               (line 109)
3382 * mpf_clear:                             Initializing Floats. (line  36)
3383 * mpf_clears:                            Initializing Floats. (line  40)
3384 * mpf_cmp:                               Float Comparison.    (line   6)
3385 * mpf_cmp_d:                             Float Comparison.    (line   8)
3386 * mpf_cmp_si:                            Float Comparison.    (line  10)
3387 * mpf_cmp_ui:                            Float Comparison.    (line   9)
3388 * mpf_cmp_z:                             Float Comparison.    (line   7)
3389 * mpf_div:                               Float Arithmetic.    (line  28)
3390 * mpf_div_2exp:                          Float Arithmetic.    (line  53)
3391 * mpf_div_ui:                            Float Arithmetic.    (line  31)
3392 * mpf_eq:                                Float Comparison.    (line  17)
3393 * mpf_fits_sint_p:                       Miscellaneous Float Functions.
3394                                                               (line  19)
3395 * mpf_fits_slong_p:                      Miscellaneous Float Functions.
3396                                                               (line  17)
3397 * mpf_fits_sshort_p:                     Miscellaneous Float Functions.
3398                                                               (line  21)
3399 * mpf_fits_uint_p:                       Miscellaneous Float Functions.
3400                                                               (line  18)
3401 * mpf_fits_ulong_p:                      Miscellaneous Float Functions.
3402                                                               (line  16)
3403 * mpf_fits_ushort_p:                     Miscellaneous Float Functions.
3404                                                               (line  20)
3405 * mpf_floor:                             Miscellaneous Float Functions.
3406                                                               (line   7)
3407 * mpf_get_d:                             Converting Floats.   (line   6)
3408 * mpf_get_default_prec:                  Initializing Floats. (line  11)
3409 * mpf_get_d_2exp:                        Converting Floats.   (line  15)
3410 * mpf_get_prec:                          Initializing Floats. (line  61)
3411 * mpf_get_si:                            Converting Floats.   (line  27)
3412 * mpf_get_str:                           Converting Floats.   (line  36)
3413 * mpf_get_ui:                            Converting Floats.   (line  28)
3414 * mpf_init:                              Initializing Floats. (line  18)
3415 * mpf_init2:                             Initializing Floats. (line  25)
3416 * mpf_inits:                             Initializing Floats. (line  30)
3417 * mpf_init_set:                          Simultaneous Float Init & Assign.
3418                                                               (line  15)
3419 * mpf_init_set_d:                        Simultaneous Float Init & Assign.
3420                                                               (line  18)
3421 * mpf_init_set_si:                       Simultaneous Float Init & Assign.
3422                                                               (line  17)
3423 * mpf_init_set_str:                      Simultaneous Float Init & Assign.
3424                                                               (line  24)
3425 * mpf_init_set_ui:                       Simultaneous Float Init & Assign.
3426                                                               (line  16)
3427 * mpf_inp_str:                           I/O of Floats.       (line  38)
3428 * mpf_integer_p:                         Miscellaneous Float Functions.
3429                                                               (line  13)
3430 * mpf_mul:                               Float Arithmetic.    (line  18)
3431 * mpf_mul_2exp:                          Float Arithmetic.    (line  49)
3432 * mpf_mul_ui:                            Float Arithmetic.    (line  19)
3433 * mpf_neg:                               Float Arithmetic.    (line  43)
3434 * mpf_out_str:                           I/O of Floats.       (line  17)
3435 * mpf_pow_ui:                            Float Arithmetic.    (line  39)
3436 * mpf_random2:                           Miscellaneous Float Functions.
3437                                                               (line  35)
3438 * mpf_reldiff:                           Float Comparison.    (line  28)
3439 * mpf_set:                               Assigning Floats.    (line   9)
3440 * mpf_set_d:                             Assigning Floats.    (line  12)
3441 * mpf_set_default_prec:                  Initializing Floats. (line   6)
3442 * mpf_set_prec:                          Initializing Floats. (line  64)
3443 * mpf_set_prec_raw:                      Initializing Floats. (line  71)
3444 * mpf_set_q:                             Assigning Floats.    (line  14)
3445 * mpf_set_si:                            Assigning Floats.    (line  11)
3446 * mpf_set_str:                           Assigning Floats.    (line  17)
3447 * mpf_set_ui:                            Assigning Floats.    (line  10)
3448 * mpf_set_z:                             Assigning Floats.    (line  13)
3449 * mpf_sgn:                               Float Comparison.    (line  33)
3450 * mpf_sqrt:                              Float Arithmetic.    (line  35)
3451 * mpf_sqrt_ui:                           Float Arithmetic.    (line  36)
3452 * mpf_sub:                               Float Arithmetic.    (line  11)
3453 * mpf_sub_ui:                            Float Arithmetic.    (line  14)
3454 * mpf_swap:                              Assigning Floats.    (line  50)
3455 * mpf_t:                                 Nomenclature and Types.
3456                                                               (line  21)
3457 * mpf_trunc:                             Miscellaneous Float Functions.
3458                                                               (line   8)
3459 * mpf_ui_div:                            Float Arithmetic.    (line  29)
3460 * mpf_ui_sub:                            Float Arithmetic.    (line  12)
3461 * mpf_urandomb:                          Miscellaneous Float Functions.
3462                                                               (line  25)
3463 * mpn_add:                               Low-level Functions. (line  67)
3464 * mpn_addmul_1:                          Low-level Functions. (line 148)
3465 * mpn_add_1:                             Low-level Functions. (line  62)
3466 * mpn_add_n:                             Low-level Functions. (line  52)
3467 * mpn_andn_n:                            Low-level Functions. (line 462)
3468 * mpn_and_n:                             Low-level Functions. (line 447)
3469 * mpn_cmp:                               Low-level Functions. (line 293)
3470 * mpn_cnd_add_n:                         Low-level Functions. (line 540)
3471 * mpn_cnd_sub_n:                         Low-level Functions. (line 542)
3472 * mpn_cnd_swap:                          Low-level Functions. (line 567)
3473 * mpn_com:                               Low-level Functions. (line 487)
3474 * mpn_copyd:                             Low-level Functions. (line 496)
3475 * mpn_copyi:                             Low-level Functions. (line 492)
3476 * mpn_divexact_1:                        Low-level Functions. (line 231)
3477 * mpn_divexact_by3:                      Low-level Functions. (line 238)
3478 * mpn_divexact_by3c:                     Low-level Functions. (line 240)
3479 * mpn_divmod:                            Low-level Functions. (line 226)
3480 * mpn_divmod_1:                          Low-level Functions. (line 210)
3481 * mpn_divrem:                            Low-level Functions. (line 183)
3482 * mpn_divrem_1:                          Low-level Functions. (line 208)
3483 * mpn_gcd:                               Low-level Functions. (line 301)
3484 * mpn_gcdext:                            Low-level Functions. (line 316)
3485 * mpn_gcd_1:                             Low-level Functions. (line 311)
3486 * mpn_get_str:                           Low-level Functions. (line 371)
3487 * mpn_hamdist:                           Low-level Functions. (line 436)
3488 * mpn_iorn_n:                            Low-level Functions. (line 467)
3489 * mpn_ior_n:                             Low-level Functions. (line 452)
3490 * mpn_lshift:                            Low-level Functions. (line 269)
3491 * mpn_mod_1:                             Low-level Functions. (line 264)
3492 * mpn_mul:                               Low-level Functions. (line 114)
3493 * mpn_mul_1:                             Low-level Functions. (line 133)
3494 * mpn_mul_n:                             Low-level Functions. (line 103)
3495 * mpn_nand_n:                            Low-level Functions. (line 472)
3496 * mpn_neg:                               Low-level Functions. (line  96)
3497 * mpn_nior_n:                            Low-level Functions. (line 477)
3498 * mpn_perfect_square_p:                  Low-level Functions. (line 442)
3499 * mpn_popcount:                          Low-level Functions. (line 432)
3500 * mpn_random:                            Low-level Functions. (line 422)
3501 * mpn_random2:                           Low-level Functions. (line 423)
3502 * mpn_rshift:                            Low-level Functions. (line 281)
3503 * mpn_scan0:                             Low-level Functions. (line 406)
3504 * mpn_scan1:                             Low-level Functions. (line 414)
3505 * mpn_sec_add_1:                         Low-level Functions. (line 553)
3506 * mpn_sec_div_qr:                        Low-level Functions. (line 630)
3507 * mpn_sec_div_qr_itch:                   Low-level Functions. (line 633)
3508 * mpn_sec_div_r:                         Low-level Functions. (line 649)
3509 * mpn_sec_div_r_itch:                    Low-level Functions. (line 651)
3510 * mpn_sec_invert:                        Low-level Functions. (line 665)
3511 * mpn_sec_invert_itch:                   Low-level Functions. (line 667)
3512 * mpn_sec_mul:                           Low-level Functions. (line 574)
3513 * mpn_sec_mul_itch:                      Low-level Functions. (line 577)
3514 * mpn_sec_powm:                          Low-level Functions. (line 604)
3515 * mpn_sec_powm_itch:                     Low-level Functions. (line 607)
3516 * mpn_sec_sqr:                           Low-level Functions. (line 590)
3517 * mpn_sec_sqr_itch:                      Low-level Functions. (line 592)
3518 * mpn_sec_sub_1:                         Low-level Functions. (line 555)
3519 * mpn_sec_tabselect:                     Low-level Functions. (line 622)
3520 * mpn_set_str:                           Low-level Functions. (line 386)
3521 * mpn_sizeinbase:                        Low-level Functions. (line 364)
3522 * mpn_sqr:                               Low-level Functions. (line 125)
3523 * mpn_sqrtrem:                           Low-level Functions. (line 346)
3524 * mpn_sub:                               Low-level Functions. (line  88)
3525 * mpn_submul_1:                          Low-level Functions. (line 160)
3526 * mpn_sub_1:                             Low-level Functions. (line  83)
3527 * mpn_sub_n:                             Low-level Functions. (line  74)
3528 * mpn_tdiv_qr:                           Low-level Functions. (line 172)
3529 * mpn_xnor_n:                            Low-level Functions. (line 482)
3530 * mpn_xor_n:                             Low-level Functions. (line 457)
3531 * mpn_zero:                              Low-level Functions. (line 500)
3532 * mpn_zero_p:                            Low-level Functions. (line 298)
3533 * mpq_abs:                               Rational Arithmetic. (line  33)
3534 * mpq_add:                               Rational Arithmetic. (line   6)
3535 * mpq_canonicalize:                      Rational Number Functions.
3536                                                               (line  21)
3537 * mpq_class:                             C++ Interface General.
3538                                                               (line  18)
3539 * mpq_class::canonicalize:               C++ Interface Rationals.
3540                                                               (line  41)
3541 * mpq_class::get_d:                      C++ Interface Rationals.
3542                                                               (line  51)
3543 * mpq_class::get_den:                    C++ Interface Rationals.
3544                                                               (line  67)
3545 * mpq_class::get_den_mpz_t:              C++ Interface Rationals.
3546                                                               (line  77)
3547 * mpq_class::get_mpq_t:                  C++ Interface General.
3548                                                               (line  64)
3549 * mpq_class::get_num:                    C++ Interface Rationals.
3550                                                               (line  66)
3551 * mpq_class::get_num_mpz_t:              C++ Interface Rationals.
3552                                                               (line  76)
3553 * mpq_class::get_str:                    C++ Interface Rationals.
3554                                                               (line  52)
3555 * mpq_class::mpq_class:                  C++ Interface Rationals.
3556                                                               (line   9)
3557 * mpq_class::mpq_class <1>:              C++ Interface Rationals.
3558                                                               (line  10)
3559 * mpq_class::mpq_class <2>:              C++ Interface Rationals.
3560                                                               (line  21)
3561 * mpq_class::mpq_class <3>:              C++ Interface Rationals.
3562                                                               (line  26)
3563 * mpq_class::mpq_class <4>:              C++ Interface Rationals.
3564                                                               (line  28)
3565 * mpq_class::set_str:                    C++ Interface Rationals.
3566                                                               (line  54)
3567 * mpq_class::set_str <1>:                C++ Interface Rationals.
3568                                                               (line  55)
3569 * mpq_class::swap:                       C++ Interface Rationals.
3570                                                               (line  58)
3571 * mpq_clear:                             Initializing Rationals.
3572                                                               (line  15)
3573 * mpq_clears:                            Initializing Rationals.
3574                                                               (line  19)
3575 * mpq_cmp:                               Comparing Rationals. (line   6)
3576 * mpq_cmp_si:                            Comparing Rationals. (line  16)
3577 * mpq_cmp_ui:                            Comparing Rationals. (line  14)
3578 * mpq_cmp_z:                             Comparing Rationals. (line   7)
3579 * mpq_denref:                            Applying Integer Functions.
3580                                                               (line  16)
3581 * mpq_div:                               Rational Arithmetic. (line  22)
3582 * mpq_div_2exp:                          Rational Arithmetic. (line  26)
3583 * mpq_equal:                             Comparing Rationals. (line  33)
3584 * mpq_get_d:                             Rational Conversions.
3585                                                               (line   6)
3586 * mpq_get_den:                           Applying Integer Functions.
3587                                                               (line  22)
3588 * mpq_get_num:                           Applying Integer Functions.
3589                                                               (line  21)
3590 * mpq_get_str:                           Rational Conversions.
3591                                                               (line  21)
3592 * mpq_init:                              Initializing Rationals.
3593                                                               (line   6)
3594 * mpq_inits:                             Initializing Rationals.
3595                                                               (line  11)
3596 * mpq_inp_str:                           I/O of Rationals.    (line  32)
3597 * mpq_inv:                               Rational Arithmetic. (line  36)
3598 * mpq_mul:                               Rational Arithmetic. (line  14)
3599 * mpq_mul_2exp:                          Rational Arithmetic. (line  18)
3600 * mpq_neg:                               Rational Arithmetic. (line  30)
3601 * mpq_numref:                            Applying Integer Functions.
3602                                                               (line  15)
3603 * mpq_out_str:                           I/O of Rationals.    (line  17)
3604 * mpq_set:                               Initializing Rationals.
3605                                                               (line  23)
3606 * mpq_set_d:                             Rational Conversions.
3607                                                               (line  16)
3608 * mpq_set_den:                           Applying Integer Functions.
3609                                                               (line  24)
3610 * mpq_set_f:                             Rational Conversions.
3611                                                               (line  17)
3612 * mpq_set_num:                           Applying Integer Functions.
3613                                                               (line  23)
3614 * mpq_set_si:                            Initializing Rationals.
3615                                                               (line  29)
3616 * mpq_set_str:                           Initializing Rationals.
3617                                                               (line  35)
3618 * mpq_set_ui:                            Initializing Rationals.
3619                                                               (line  27)
3620 * mpq_set_z:                             Initializing Rationals.
3621                                                               (line  24)
3622 * mpq_sgn:                               Comparing Rationals. (line  27)
3623 * mpq_sub:                               Rational Arithmetic. (line  10)
3624 * mpq_swap:                              Initializing Rationals.
3625                                                               (line  54)
3626 * mpq_t:                                 Nomenclature and Types.
3627                                                               (line  16)
3628 * mpz_2fac_ui:                           Number Theoretic Functions.
3629                                                               (line 113)
3630 * mpz_abs:                               Integer Arithmetic.  (line  44)
3631 * mpz_add:                               Integer Arithmetic.  (line   6)
3632 * mpz_addmul:                            Integer Arithmetic.  (line  24)
3633 * mpz_addmul_ui:                         Integer Arithmetic.  (line  26)
3634 * mpz_add_ui:                            Integer Arithmetic.  (line   7)
3635 * mpz_and:                               Integer Logic and Bit Fiddling.
3636                                                               (line  10)
3637 * mpz_array_init:                        Integer Special Functions.
3638                                                               (line   9)
3639 * mpz_bin_ui:                            Number Theoretic Functions.
3640                                                               (line 124)
3641 * mpz_bin_uiui:                          Number Theoretic Functions.
3642                                                               (line 126)
3643 * mpz_cdiv_q:                            Integer Division.    (line  12)
3644 * mpz_cdiv_qr:                           Integer Division.    (line  14)
3645 * mpz_cdiv_qr_ui:                        Integer Division.    (line  21)
3646 * mpz_cdiv_q_2exp:                       Integer Division.    (line  26)
3647 * mpz_cdiv_q_ui:                         Integer Division.    (line  17)
3648 * mpz_cdiv_r:                            Integer Division.    (line  13)
3649 * mpz_cdiv_r_2exp:                       Integer Division.    (line  29)
3650 * mpz_cdiv_r_ui:                         Integer Division.    (line  19)
3651 * mpz_cdiv_ui:                           Integer Division.    (line  23)
3652 * mpz_class:                             C++ Interface General.
3653                                                               (line  17)
3654 * mpz_class::factorial:                  C++ Interface Integers.
3655                                                               (line  70)
3656 * mpz_class::fibonacci:                  C++ Interface Integers.
3657                                                               (line  74)
3658 * mpz_class::fits_sint_p:                C++ Interface Integers.
3659                                                               (line  50)
3660 * mpz_class::fits_slong_p:               C++ Interface Integers.
3661                                                               (line  51)
3662 * mpz_class::fits_sshort_p:              C++ Interface Integers.
3663                                                               (line  52)
3664 * mpz_class::fits_uint_p:                C++ Interface Integers.
3665                                                               (line  54)
3666 * mpz_class::fits_ulong_p:               C++ Interface Integers.
3667                                                               (line  55)
3668 * mpz_class::fits_ushort_p:              C++ Interface Integers.
3669                                                               (line  56)
3670 * mpz_class::get_d:                      C++ Interface Integers.
3671                                                               (line  58)
3672 * mpz_class::get_mpz_t:                  C++ Interface General.
3673                                                               (line  63)
3674 * mpz_class::get_si:                     C++ Interface Integers.
3675                                                               (line  59)
3676 * mpz_class::get_str:                    C++ Interface Integers.
3677                                                               (line  60)
3678 * mpz_class::get_ui:                     C++ Interface Integers.
3679                                                               (line  61)
3680 * mpz_class::mpz_class:                  C++ Interface Integers.
3681                                                               (line   6)
3682 * mpz_class::mpz_class <1>:              C++ Interface Integers.
3683                                                               (line  14)
3684 * mpz_class::mpz_class <2>:              C++ Interface Integers.
3685                                                               (line  19)
3686 * mpz_class::mpz_class <3>:              C++ Interface Integers.
3687                                                               (line  21)
3688 * mpz_class::primorial:                  C++ Interface Integers.
3689                                                               (line  72)
3690 * mpz_class::set_str:                    C++ Interface Integers.
3691                                                               (line  63)
3692 * mpz_class::set_str <1>:                C++ Interface Integers.
3693                                                               (line  64)
3694 * mpz_class::swap:                       C++ Interface Integers.
3695                                                               (line  77)
3696 * mpz_clear:                             Initializing Integers.
3697                                                               (line  48)
3698 * mpz_clears:                            Initializing Integers.
3699                                                               (line  52)
3700 * mpz_clrbit:                            Integer Logic and Bit Fiddling.
3701                                                               (line  54)
3702 * mpz_cmp:                               Integer Comparisons. (line   6)
3703 * mpz_cmpabs:                            Integer Comparisons. (line  17)
3704 * mpz_cmpabs_d:                          Integer Comparisons. (line  18)
3705 * mpz_cmpabs_ui:                         Integer Comparisons. (line  19)
3706 * mpz_cmp_d:                             Integer Comparisons. (line   7)
3707 * mpz_cmp_si:                            Integer Comparisons. (line   8)
3708 * mpz_cmp_ui:                            Integer Comparisons. (line   9)
3709 * mpz_com:                               Integer Logic and Bit Fiddling.
3710                                                               (line  19)
3711 * mpz_combit:                            Integer Logic and Bit Fiddling.
3712                                                               (line  57)
3713 * mpz_congruent_2exp_p:                  Integer Division.    (line 148)
3714 * mpz_congruent_p:                       Integer Division.    (line 144)
3715 * mpz_congruent_ui_p:                    Integer Division.    (line 146)
3716 * mpz_divexact:                          Integer Division.    (line 122)
3717 * mpz_divexact_ui:                       Integer Division.    (line 123)
3718 * mpz_divisible_2exp_p:                  Integer Division.    (line 135)
3719 * mpz_divisible_p:                       Integer Division.    (line 132)
3720 * mpz_divisible_ui_p:                    Integer Division.    (line 133)
3721 * mpz_even_p:                            Miscellaneous Integer Functions.
3722                                                               (line  17)
3723 * mpz_export:                            Integer Import and Export.
3724                                                               (line  43)
3725 * mpz_fac_ui:                            Number Theoretic Functions.
3726                                                               (line 112)
3727 * mpz_fdiv_q:                            Integer Division.    (line  33)
3728 * mpz_fdiv_qr:                           Integer Division.    (line  35)
3729 * mpz_fdiv_qr_ui:                        Integer Division.    (line  42)
3730 * mpz_fdiv_q_2exp:                       Integer Division.    (line  47)
3731 * mpz_fdiv_q_ui:                         Integer Division.    (line  38)
3732 * mpz_fdiv_r:                            Integer Division.    (line  34)
3733 * mpz_fdiv_r_2exp:                       Integer Division.    (line  50)
3734 * mpz_fdiv_r_ui:                         Integer Division.    (line  40)
3735 * mpz_fdiv_ui:                           Integer Division.    (line  44)
3736 * mpz_fib2_ui:                           Number Theoretic Functions.
3737                                                               (line 134)
3738 * mpz_fib_ui:                            Number Theoretic Functions.
3739                                                               (line 133)
3740 * mpz_fits_sint_p:                       Miscellaneous Integer Functions.
3741                                                               (line   9)
3742 * mpz_fits_slong_p:                      Miscellaneous Integer Functions.
3743                                                               (line   7)
3744 * mpz_fits_sshort_p:                     Miscellaneous Integer Functions.
3745                                                               (line  11)
3746 * mpz_fits_uint_p:                       Miscellaneous Integer Functions.
3747                                                               (line   8)
3748 * mpz_fits_ulong_p:                      Miscellaneous Integer Functions.
3749                                                               (line   6)
3750 * mpz_fits_ushort_p:                     Miscellaneous Integer Functions.
3751                                                               (line  10)
3752 * mpz_gcd:                               Number Theoretic Functions.
3753                                                               (line  29)
3754 * mpz_gcdext:                            Number Theoretic Functions.
3755                                                               (line  45)
3756 * mpz_gcd_ui:                            Number Theoretic Functions.
3757                                                               (line  35)
3758 * mpz_getlimbn:                          Integer Special Functions.
3759                                                               (line  22)
3760 * mpz_get_d:                             Converting Integers. (line  26)
3761 * mpz_get_d_2exp:                        Converting Integers. (line  34)
3762 * mpz_get_si:                            Converting Integers. (line  17)
3763 * mpz_get_str:                           Converting Integers. (line  46)
3764 * mpz_get_ui:                            Converting Integers. (line  10)
3765 * mpz_hamdist:                           Integer Logic and Bit Fiddling.
3766                                                               (line  28)
3767 * mpz_import:                            Integer Import and Export.
3768                                                               (line   9)
3769 * mpz_init:                              Initializing Integers.
3770                                                               (line  25)
3771 * mpz_init2:                             Initializing Integers.
3772                                                               (line  32)
3773 * mpz_inits:                             Initializing Integers.
3774                                                               (line  28)
3775 * mpz_init_set:                          Simultaneous Integer Init & Assign.
3776                                                               (line  26)
3777 * mpz_init_set_d:                        Simultaneous Integer Init & Assign.
3778                                                               (line  29)
3779 * mpz_init_set_si:                       Simultaneous Integer Init & Assign.
3780                                                               (line  28)
3781 * mpz_init_set_str:                      Simultaneous Integer Init & Assign.
3782                                                               (line  33)
3783 * mpz_init_set_ui:                       Simultaneous Integer Init & Assign.
3784                                                               (line  27)
3785 * mpz_inp_raw:                           I/O of Integers.     (line  61)
3786 * mpz_inp_str:                           I/O of Integers.     (line  30)
3787 * mpz_invert:                            Number Theoretic Functions.
3788                                                               (line  72)
3789 * mpz_ior:                               Integer Logic and Bit Fiddling.
3790                                                               (line  13)
3791 * mpz_jacobi:                            Number Theoretic Functions.
3792                                                               (line  82)
3793 * mpz_kronecker:                         Number Theoretic Functions.
3794                                                               (line  90)
3795 * mpz_kronecker_si:                      Number Theoretic Functions.
3796                                                               (line  91)
3797 * mpz_kronecker_ui:                      Number Theoretic Functions.
3798                                                               (line  92)
3799 * mpz_lcm:                               Number Theoretic Functions.
3800                                                               (line  65)
3801 * mpz_lcm_ui:                            Number Theoretic Functions.
3802                                                               (line  66)
3803 * mpz_legendre:                          Number Theoretic Functions.
3804                                                               (line  85)
3805 * mpz_limbs_finish:                      Integer Special Functions.
3806                                                               (line  47)
3807 * mpz_limbs_modify:                      Integer Special Functions.
3808                                                               (line  40)
3809 * mpz_limbs_read:                        Integer Special Functions.
3810                                                               (line  34)
3811 * mpz_limbs_write:                       Integer Special Functions.
3812                                                               (line  39)
3813 * mpz_lucnum2_ui:                        Number Theoretic Functions.
3814                                                               (line 145)
3815 * mpz_lucnum_ui:                         Number Theoretic Functions.
3816                                                               (line 144)
3817 * mpz_mfac_uiui:                         Number Theoretic Functions.
3818                                                               (line 114)
3819 * mpz_mod:                               Integer Division.    (line 112)
3820 * mpz_mod_ui:                            Integer Division.    (line 113)
3821 * mpz_mul:                               Integer Arithmetic.  (line  18)
3822 * mpz_mul_2exp:                          Integer Arithmetic.  (line  36)
3823 * mpz_mul_si:                            Integer Arithmetic.  (line  19)
3824 * mpz_mul_ui:                            Integer Arithmetic.  (line  20)
3825 * mpz_neg:                               Integer Arithmetic.  (line  41)
3826 * mpz_nextprime:                         Number Theoretic Functions.
3827                                                               (line  22)
3828 * mpz_odd_p:                             Miscellaneous Integer Functions.
3829                                                               (line  16)
3830 * mpz_out_raw:                           I/O of Integers.     (line  45)
3831 * mpz_out_str:                           I/O of Integers.     (line  17)
3832 * mpz_perfect_power_p:                   Integer Roots.       (line  27)
3833 * mpz_perfect_square_p:                  Integer Roots.       (line  36)
3834 * mpz_popcount:                          Integer Logic and Bit Fiddling.
3835                                                               (line  22)
3836 * mpz_powm:                              Integer Exponentiation.
3837                                                               (line   6)
3838 * mpz_powm_sec:                          Integer Exponentiation.
3839                                                               (line  16)
3840 * mpz_powm_ui:                           Integer Exponentiation.
3841                                                               (line   8)
3842 * mpz_pow_ui:                            Integer Exponentiation.
3843                                                               (line  29)
3844 * mpz_primorial_ui:                      Number Theoretic Functions.
3845                                                               (line 120)
3846 * mpz_probab_prime_p:                    Number Theoretic Functions.
3847                                                               (line   6)
3848 * mpz_random:                            Integer Random Numbers.
3849                                                               (line  41)
3850 * mpz_random2:                           Integer Random Numbers.
3851                                                               (line  50)
3852 * mpz_realloc2:                          Initializing Integers.
3853                                                               (line  56)
3854 * mpz_remove:                            Number Theoretic Functions.
3855                                                               (line 106)
3856 * mpz_roinit_n:                          Integer Special Functions.
3857                                                               (line  67)
3858 * MPZ_ROINIT_N:                          Integer Special Functions.
3859                                                               (line  83)
3860 * mpz_root:                              Integer Roots.       (line   6)
3861 * mpz_rootrem:                           Integer Roots.       (line  12)
3862 * mpz_rrandomb:                          Integer Random Numbers.
3863                                                               (line  29)
3864 * mpz_scan0:                             Integer Logic and Bit Fiddling.
3865                                                               (line  35)
3866 * mpz_scan1:                             Integer Logic and Bit Fiddling.
3867                                                               (line  37)
3868 * mpz_set:                               Assigning Integers.  (line   9)
3869 * mpz_setbit:                            Integer Logic and Bit Fiddling.
3870                                                               (line  51)
3871 * mpz_set_d:                             Assigning Integers.  (line  12)
3872 * mpz_set_f:                             Assigning Integers.  (line  14)
3873 * mpz_set_q:                             Assigning Integers.  (line  13)
3874 * mpz_set_si:                            Assigning Integers.  (line  11)
3875 * mpz_set_str:                           Assigning Integers.  (line  20)
3876 * mpz_set_ui:                            Assigning Integers.  (line  10)
3877 * mpz_sgn:                               Integer Comparisons. (line  27)
3878 * mpz_size:                              Integer Special Functions.
3879                                                               (line  30)
3880 * mpz_sizeinbase:                        Miscellaneous Integer Functions.
3881                                                               (line  22)
3882 * mpz_si_kronecker:                      Number Theoretic Functions.
3883                                                               (line  93)
3884 * mpz_sqrt:                              Integer Roots.       (line  17)
3885 * mpz_sqrtrem:                           Integer Roots.       (line  20)
3886 * mpz_sub:                               Integer Arithmetic.  (line  11)
3887 * mpz_submul:                            Integer Arithmetic.  (line  30)
3888 * mpz_submul_ui:                         Integer Arithmetic.  (line  32)
3889 * mpz_sub_ui:                            Integer Arithmetic.  (line  12)
3890 * mpz_swap:                              Assigning Integers.  (line  36)
3891 * mpz_t:                                 Nomenclature and Types.
3892                                                               (line   6)
3893 * mpz_tdiv_q:                            Integer Division.    (line  54)
3894 * mpz_tdiv_qr:                           Integer Division.    (line  56)
3895 * mpz_tdiv_qr_ui:                        Integer Division.    (line  63)
3896 * mpz_tdiv_q_2exp:                       Integer Division.    (line  68)
3897 * mpz_tdiv_q_ui:                         Integer Division.    (line  59)
3898 * mpz_tdiv_r:                            Integer Division.    (line  55)
3899 * mpz_tdiv_r_2exp:                       Integer Division.    (line  71)
3900 * mpz_tdiv_r_ui:                         Integer Division.    (line  61)
3901 * mpz_tdiv_ui:                           Integer Division.    (line  65)
3902 * mpz_tstbit:                            Integer Logic and Bit Fiddling.
3903                                                               (line  60)
3904 * mpz_ui_kronecker:                      Number Theoretic Functions.
3905                                                               (line  94)
3906 * mpz_ui_pow_ui:                         Integer Exponentiation.
3907                                                               (line  31)
3908 * mpz_ui_sub:                            Integer Arithmetic.  (line  14)
3909 * mpz_urandomb:                          Integer Random Numbers.
3910                                                               (line  12)
3911 * mpz_urandomm:                          Integer Random Numbers.
3912                                                               (line  21)
3913 * mpz_xor:                               Integer Logic and Bit Fiddling.
3914                                                               (line  16)
3915 * mp_bitcnt_t:                           Nomenclature and Types.
3916                                                               (line  42)
3917 * mp_bits_per_limb:                      Useful Macros and Constants.
3918                                                               (line   7)
3919 * mp_exp_t:                              Nomenclature and Types.
3920                                                               (line  27)
3921 * mp_get_memory_functions:               Custom Allocation.   (line  86)
3922 * mp_limb_t:                             Nomenclature and Types.
3923                                                               (line  31)
3924 * mp_set_memory_functions:               Custom Allocation.   (line  14)
3925 * mp_size_t:                             Nomenclature and Types.
3926                                                               (line  37)
3927 * operator"":                            C++ Interface Integers.
3928                                                               (line  29)
3929 * operator"" <1>:                        C++ Interface Rationals.
3930                                                               (line  36)
3931 * operator"" <2>:                        C++ Interface Floats.
3932                                                               (line  55)
3933 * operator%:                             C++ Interface Integers.
3934                                                               (line  34)
3935 * operator/:                             C++ Interface Integers.
3936                                                               (line  33)
3937 * operator<<:                            C++ Formatted Output.
3938                                                               (line  10)
3939 * operator<< <1>:                        C++ Formatted Output.
3940                                                               (line  19)
3941 * operator<< <2>:                        C++ Formatted Output.
3942                                                               (line  32)
3943 * operator>>:                            C++ Formatted Input. (line  10)
3944 * operator>> <1>:                        C++ Formatted Input. (line  13)
3945 * operator>> <2>:                        C++ Formatted Input. (line  24)
3946 * operator>> <3>:                        C++ Interface Rationals.
3947                                                               (line  86)
3948 * primorial:                             C++ Interface Integers.
3949                                                               (line  73)
3950 * sgn:                                   C++ Interface Integers.
3951                                                               (line  65)
3952 * sgn <1>:                               C++ Interface Rationals.
3953                                                               (line  56)
3954 * sgn <2>:                               C++ Interface Floats.
3955                                                               (line 106)
3956 * sqrt:                                  C++ Interface Integers.
3957                                                               (line  66)
3958 * sqrt <1>:                              C++ Interface Floats.
3959                                                               (line 107)
3960 * swap:                                  C++ Interface Integers.
3961                                                               (line  78)
3962 * swap <1>:                              C++ Interface Rationals.
3963                                                               (line  59)
3964 * swap <2>:                              C++ Interface Floats.
3965                                                               (line 110)
3966 * trunc:                                 C++ Interface Floats.
3967                                                               (line 111)
3968